From 4dfb59cf39207b7979c5a0f274f7b1791d1b3c92 Mon Sep 17 00:00:00 2001 From: seapehim Date: Thu, 13 Jun 2024 12:38:48 +0200 Subject: [PATCH] Modified the eRegister Weekly report - included intakes and registered --- Serialized_Object.sql | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Serialized_Object.sql b/Serialized_Object.sql index 589c5d5..2e4126c 100644 --- a/Serialized_Object.sql +++ b/Serialized_Object.sql @@ -47,7 +47,7 @@ CREATE TABLE `serialized_object` ( CONSTRAINT `serialized_object_changed_by` FOREIGN KEY (`changed_by`) REFERENCES `users` (`user_id`), CONSTRAINT `serialized_object_creator` FOREIGN KEY (`creator`) REFERENCES `users` (`user_id`), CONSTRAINT `serialized_object_retired_by` FOREIGN KEY (`retired_by`) REFERENCES `users` (`user_id`) -) ENGINE=InnoDB AUTO_INCREMENT=2728 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=2859 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -57,21 +57,22 @@ CREATE TABLE `serialized_object` ( LOCK TABLES `serialized_object` WRITE; /*!40000 ALTER TABLE `serialized_object` DISABLE KEYS */; INSERT INTO `serialized_object` VALUES (1,'ART Monthly Period Indicator Report','Period indicator report to be used to report to DHIS2 Lesotho Monthly ART Aggregate Report','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART Monthly Period Indicator Report\n Period indicator report to be used to report to DHIS2 Lesotho Monthly ART Aggregate Report\n \n 2018-02-21 08:48:22 UTC\n \n 2018-03-01 07:14: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 1\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','2018-02-21 08:48:22',4,'2018-03-01 07:14:19',4,0,NULL,NULL,NULL,'c097de3d-fba8-40f1-ba07-580002f61d2b'),(2,'ART_test Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART_test Data Set\n \n 2018-02-21 08:48:23 UTC\n \n 2018-07-11 11:24: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 2\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n \n \n \n \n 001\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 Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n 002\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n 003\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n 004\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n 005\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n 006\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n 007\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n 008\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n 009\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n 010\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n 011\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n 012\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n 013\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 25to49yrs\n \n \n \n \n \n 014\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 25to49yrs\n \n \n \n \n \n 015\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 50+yrs\n \n \n \n \n \n 016\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 50+yrs\n \n \n \n \n \n 017\n \n \n \n \n \n \n \n \n 018\n \n \n \n \n \n \n 019\n \n \n \n \n \n \n 020\n \n \n \n \n \n \n 021\n \n \n \n \n \n \n 022\n \n \n \n \n \n \n 023\n \n \n \n \n \n \n 024\n \n \n \n \n \n \n 025\n \n \n \n \n \n \n 026\n \n \n \n \n \n \n 027\n \n \n \n \n \n \n 028\n \n \n \n \n \n \n 029\n \n \n \n \n \n \n 030\n \n \n \n \n \n \n 031\n \n \n \n \n \n \n 032\n \n \n \n \n \n \n 033\n \n \n \n \n \n \n \n \n \n 034\n \n \n \n \n \n \n 035\n \n \n \n \n \n \n 036\n \n \n \n \n \n \n 037\n \n \n \n \n \n \n 038\n \n \n \n \n \n \n 039\n \n \n \n \n \n \n 040\n \n \n \n \n \n \n 041\n \n \n \n \n \n \n 042\n \n \n \n \n \n \n 043\n \n \n \n \n \n \n 044\n \n \n \n \n \n \n 045\n \n \n \n \n \n \n 046\n \n \n \n \n \n \n 047\n \n \n \n \n \n \n 048\n \n \n \n \n \n \n 049\n \n \n \n \n \n \n \n \n \n 050\n \n \n \n \n \n \n \n \n \n 051\n \n \n \n \n \n \n \n \n \n 052\n \n \n \n \n \n \n \n \n \n 053\n \n \n \n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 054\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 055\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Adults\n \n \n \n \n \n 056\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Adults\n \n \n \n \n \n 057\n \n \n \n \n \n \n \n \n \n 058\n \n \n \n \n \n \n 059\n \n \n \n \n \n \n 060\n \n \n \n \n \n \n 192\n \n \n \n \n \n \n \n \n \n 193\n \n \n \n \n \n \n 194\n \n \n \n \n \n \n 195\n \n \n \n \n \n \n 196\n \n \n \n \n \n \n 197\n \n \n \n \n \n \n 198\n \n \n \n \n \n \n 199\n \n \n \n \n \n \n 200\n \n \n \n \n \n \n 201\n \n \n \n \n \n \n 202\n \n \n \n \n \n \n 203\n \n \n \n \n \n \n 204\n \n \n \n \n \n \n 205\n \n \n \n \n \n \n 206\n \n \n \n \n \n \n 207\n \n \n \n \n \n \n 208\n \n \n \n \n \n \n \n \n \n 209\n \n \n \n \n \n \n 210\n \n \n \n \n \n \n 211\n \n \n \n \n \n \n 212\n \n \n \n \n \n \n 213\n \n \n \n \n \n \n 214\n \n \n \n \n \n \n 215\n \n \n \n \n \n \n 216\n \n \n \n \n \n \n 217\n \n \n \n \n \n \n 218\n \n \n \n \n \n \n 219\n \n \n \n \n \n \n 220\n \n \n \n \n \n \n 221\n \n \n \n \n \n \n 222\n \n \n \n \n \n \n 223\n \n \n \n \n \n \n','2018-02-21 14:18:23',4,'2018-07-11 16:54:16',4,0,NULL,NULL,NULL,'0e2ab4bb-abdb-4097-916c-794d14bd9664'),(3,'Sex_Cohort_Query','Patients sex','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.GenderCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Sex_Cohort_Query\n Patients sex\n \n 2018-02-21 08:55:41 UTC\n \n 2018-02-27 09:19:19 UTC\n \n \n maleIncluded\n \n java.lang.Boolean\n true\n \n \n femaleIncluded\n \n java.lang.Boolean\n true\n \n \n 3\n false\n','2018-02-21 08:55:41',4,'2018-02-27 09:19:19',4,0,NULL,NULL,NULL,'a1ddc580-da2c-4297-8c69-866de9252263'),(4,'Age_cohort_Query','patients ages','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.AgeCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Age_cohort_Query\n patients ages\n \n 2018-02-21 09:00:07 UTC\n \n 2019-03-26 13:41:51 UTC\n \n \n minAge\n \n java.lang.Integer\n true\n \n \n maxAge\n \n java.lang.Integer\n true\n \n \n effectiveDate\n \n java.util.Date\n true\n \n \n 4\n YEARS\n YEARS\n false\n','2018-02-21 09:00:07',4,'2019-03-26 13:41:51',4,0,NULL,NULL,NULL,'f8d3dd08-0b1f-4780-b77f-97d021b803af'),(5,'ART start date','ART clients newly started on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.DateObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART start date\n ART clients newly started on ART\n \n 2018-02-21 09:08:47 UTC\n \n 2018-03-01 07:22:25 UTC\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n value1\n \n java.util.Date\n true\n \n \n value2\n \n java.util.Date\n true\n \n \n 5\n ANY\n \n \n \n \n GREATER_EQUAL\n LESS_EQUAL\n','2018-02-21 09:08:47',4,'2018-03-01 07:22:25',4,0,NULL,NULL,NULL,'3cfb3f8e-ceff-4201-8fcb-25e2d61a77c5'),(6,'CI_01: Clients newly started on ART','Cohort Indicator for clients newly started on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI_01: Clients newly started on ART\n Cohort Indicator for clients newly started on ART\n \n 2018-02-21 09:55:13 UTC\n \n 2019-01-31 18:03: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 6\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-02-21 09:55:13',4,'2019-01-31 18:03:42',4,0,NULL,NULL,NULL,'e815a8e7-ba99-4a34-9e3b-038a0fbaa34d'),(9,'DM_Age','age dimensions','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n DM_Age\n age dimensions\n \n 2018-02-27 09:21:44 UTC\n \n 2020-04-26 11:02:40 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n 9\n \n \n 01to04yrs\n \n \n \n \n maxAge\n 4\n \n \n minAge\n 1\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 05to09yrs\n \n \n \n \n maxAge\n 9\n \n \n minAge\n 5\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 05yrsto14yrs\n \n \n \n \n maxAge\n 14\n \n \n minAge\n 5\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 06Mnths-5yrs\n \n \n \n \n maxAge\n 5\n \n \n minAge\n 6\n \n \n \n \n \n 06yrs-14yrs\n \n \n \n \n maxAge\n 14\n \n \n minAge\n 6\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 0Mnths-4yrs\n \n \n \n \n maxAge\n 4\n \n \n minAge\n 0\n \n \n \n \n \n 100to150yrs\n \n \n \n \n maxAge\n 150\n \n \n minAge\n 120\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 10to14yrs\n \n \n \n \n maxAge\n 14\n \n \n minAge\n 10\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 15+yrs\n \n \n \n \n maxAge\n 120\n \n \n minAge\n 15\n \n \n \n \n \n 15to19yrs\n \n \n \n \n maxAge\n 19\n \n \n minAge\n 15\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 20to24yrs\n \n \n \n \n maxAge\n 24\n \n \n minAge\n 20\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 25to29yrs\n \n \n \n \n maxAge\n 29\n \n \n minAge\n 25\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 25to49yrs\n \n \n \n \n maxAge\n 49\n \n \n minAge\n 25\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 30to34yrs\n \n \n \n \n maxAge\n 34\n \n \n minAge\n 30\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 35to39yrs\n \n \n \n \n maxAge\n 39\n \n \n minAge\n 35\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 40to44yrs\n \n \n \n \n maxAge\n 44\n \n \n minAge\n 40\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 45to49yrs\n \n \n \n \n maxAge\n 49\n \n \n minAge\n 45\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 50+yrs\n \n \n \n \n maxAge\n 110\n \n \n minAge\n 50\n \n \n \n \n \n 50to100yrs\n \n \n \n \n maxAge\n 119\n \n \n minAge\n 50\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n <6Months\n \n \n \n \n maxAge\n 5\n \n \n minAge\n 0\n \n \n \n \n \n Adults\n \n \n \n Age_cohort_Query\n \n \n \n \n maxAge\n 100\n \n \n minAge\n 50\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n Children 0to14\n \n \n \n \n maxAge\n 14\n \n \n minAge\n 0\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n Under 1yr\n \n \n \n \n maxAge\n 0\n \n \n minAge\n 0\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n','2018-02-27 09:21:44',4,'2020-04-26 11:02:40',4,0,NULL,NULL,NULL,'93da8e26-c1ea-44e3-a0f3-f325c7797d9a'),(10,'DM_Sex','Sex dimession','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n DM_Sex\n Sex dimession\n \n 2018-02-27 09:39:18 UTC\n \n 2018-02-27 09:42:20 UTC\n \n 10\n \n \n Females\n \n \n \n \n femaleIncluded\n true\n \n \n maleIncluded\n false\n \n \n \n \n \n Males\n \n \n \n \n femaleIncluded\n false\n \n \n maleIncluded\n true\n \n \n \n \n \n','2018-02-27 09:39:18',4,'2018-02-27 09:42:20',4,0,NULL,NULL,NULL,'dec74189-72cc-4981-b956-557f37b82a87'),(11,'Weight_Cohort_Query','for weight bands','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.NumericObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Weight_Cohort_Query\n for weight bands\n \n 2018-02-27 10:06:14 UTC\n \n 2020-06-16 09:53:20 UTC\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n value1\n \n java.lang.Double\n true\n \n \n value2\n \n java.lang.Double\n true\n \n \n 11\n LAST\n \n \n \n \n GREATER_EQUAL\n LESS_EQUAL\n','2018-02-27 10:06:14',4,'2020-06-16 09:53:20',4,0,NULL,NULL,NULL,'33a425d0-d6f9-42b8-8afe-08df159de8b7'),(12,'DM_Weight','patient weight','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n DM_Weight\n patient weight\n \n 2018-02-27 10:11:05 UTC\n \n 2020-06-05 16:01:23 UTC\n \n 12\n \n \n 03to3.9kg\n \n \n \n \n value2\n 3.9\n \n \n value1\n 0.0\n \n \n \n \n \n 04to5.9kg\n \n \n \n \n locationList\n \n \n \n value2\n 5.9\n \n \n value1\n 4.0\n \n \n \n \n \n 06to9.9kg\n \n \n \n \n locationList\n \n \n \n value2\n 9.9\n \n \n value1\n 6.0\n \n \n \n \n \n 10to13.9kg\n \n \n \n \n locationList\n \n \n \n value2\n 13.9\n \n \n value1\n 10.0\n \n \n \n \n \n 14to19.9kg\n \n \n \n \n locationList\n \n \n \n value2\n 19.9\n \n \n value1\n 14.0\n \n \n \n \n \n 20to24.9kg\n \n \n \n \n locationList\n \n \n \n value2\n 24.9\n \n \n value1\n 20.0\n \n \n \n \n \n 25+kg\n \n \n \n \n locationList\n \n \n \n value2\n 200.0\n \n \n value1\n 25.0\n \n \n \n \n \n 25to34.9kg\n \n \n \n \n value2\n 34.9\n \n \n value1\n 25.0\n \n \n \n \n \n 34.9kg+\n \n \n \n \n value2\n 50.0\n \n \n value1\n 34.9\n \n \n \n \n \n','2018-02-27 12:11:05',4,'2020-06-05 18:01:23',4,0,NULL,NULL,NULL,'776ab68c-5afb-4054-8ee1-e9d6667c53cf'),(13,'Clients seen','','org.openmrs.module.reporting.query.encounter.definition.EncounterQuery','org.openmrs.module.reporting.query.encounter.definition.SqlEncounterQuery','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen\n \n \n 2018-02-27 13:17:12 UTC\n \n 2018-02-27 15:09:07 UTC\n \n \n client_type_seen\n \n org.openmrs.Concept\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 13\n select count(*) as numEncounters \nfrom encounter enc inner join obs on enc.encounter_id = obs.encounter_id \nwhere \nencounter_type = 1 and enc.location_id = 7 and \n(DATE(encounter_datetime) >= '2018-02-01' and DATE(encounter_datetime) <= '2018-02-28') and \nconcept_id = 3843 and value_coded = 3842 \nGROUP BY enc.encounter_id;\n','2018-02-27 13:17:12',4,'2018-02-27 15:09:07',4,0,NULL,NULL,NULL,'23eb8d9f-180f-4522-a23b-8298c7cedb8f'),(15,'Clients seen for consultation','Any client seen at the location specified and period (ENCOUNTER QUERY)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen for consultation\n Any client seen at the location specified and period (ENCOUNTER QUERY)\n \n 2018-02-28 11:01:22 UTC\n \n 2019-01-22 09:51:11 UTC\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n 15\n ANY\n \n \n \n 1\n','2018-02-28 13:01:22',4,'2019-01-22 11:51:11',4,0,NULL,NULL,NULL,'0b52550f-d47c-46ba-81f1-ca8aa8eeb4b3'),(16,'type of client','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n type of client\n \n \n 2018-02-28 11:06:40 UTC\n \n 2018-10-30 14:11:35 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n 16\n ANY\n \n \n \n \n IN\n \n \n \n \n','2018-02-28 13:06:40',4,'2018-10-30 16:11:35',4,0,NULL,NULL,NULL,'14d6cb12-1b59-4023-b7d7-f67a5138423a'),(17,'ART clients_seen','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients_seen\n \n \n 2018-02-28 11:08:24 UTC\n \n 2018-03-28 08:56: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 17\n type-of-client AND Clients-seen\n \n \n type-of-client\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n Clients-seen\n \n \n \n \n \n \n','2018-02-28 13:08:24',4,'2018-03-28 10:56:10',4,0,NULL,NULL,NULL,'a01c89db-b405-4c76-9f33-14e918211569'),(19,'CI03: Tx Curr Previous Months','Clients seen for ART services in the reporting period males (under 1) (excludes) new initiations','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI03: Tx Curr Previous Months\n Clients seen for ART services in the reporting period males (under 1) (excludes) new initiations\n \n 2018-03-01 07:23:08 UTC\n \n 2019-02-27 14:28: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 19\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-01 07:23:08',4,'2019-02-27 14:28:13',4,0,NULL,NULL,NULL,'ba6124a3-7406-4cd9-9f5b-32cc0c56286c'),(20,'Current on ART clients who made visits in previous 2 months','Current on ART clients who made visits in previous 2 months (2 months ARV drug supply)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Current on ART clients who made visits in previous 2 months\n Current on ART clients who made visits in previous 2 months (2 months ARV drug supply)\n \n 2018-03-01 08:15:35 UTC\n \n 2018-03-01 08:42:34 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 20\n select distinct person_id \nfrom obs o \nwhere location_id =:location \nand (o.concept_id = 3843 and o.value_coded = 3842) \nand MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH))\n','2018-03-01 08:15:35',4,'2018-03-01 08:42:34',4,0,NULL,NULL,NULL,'6fc68835-cd3f-4241-8d81-346182b4f552'),(21,'Current on ART clients who made visits in previous 3 months','ART Clients who made visits in previous 3 Months (3 months drug supply)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Current on ART clients who made visits in previous 3 months\n ART Clients who made visits in previous 3 Months (3 months drug supply)\n \n 2018-03-01 08:16:01 UTC\n \n 2018-10-30 09:18:30 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n 21\n select distinct person_id \nfrom obs o \nwhere location_id =:location \nand (o.concept_id = 3843 and o.value_coded = 3842) \nand MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH))\n','2018-03-01 10:16:01',4,'2018-10-30 11:18:30',4,0,NULL,NULL,NULL,'96bee18b-f015-4f51-9684-58a0be770afc'),(22,'Current on ART clients who made visits in the previous month','Current on ART clients who made visits in the previous month (1 month ARV Drug Supply)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Current on ART clients who made visits in the previous month\n Current on ART clients who made visits in the previous month (1 month ARV Drug Supply)\n \n 2018-03-01 08:20:17 UTC\n \n 2018-03-01 08:45:22 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 22\n select distinct person_id \nfrom obs o \nwhere location_id =:location \nand (o.concept_id = 3843 and o.value_coded = 3842) \nand MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -0 MONTH))\n','2018-03-01 08:20:17',4,'2018-03-01 08:45:22',4,0,NULL,NULL,NULL,'18b8f912-a433-4fe7-9181-44b5f752db66'),(23,'ARV Drug Supply for 2 Months','Current on ART clients who made visits in previous months (2 months ARV drug supply)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.NumericObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV Drug Supply for 2 Months\n Current on ART clients who made visits in previous months (2 months ARV drug supply)\n \n 2018-03-01 08:59:39 UTC\n \n 2018-03-01 18:11:21 UTC\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n 23\n ANY\n \n \n \n \n GREATER_THAN\n 30.0\n','2018-03-01 08:59:39',4,'2018-03-01 18:11:21',4,0,NULL,NULL,NULL,'fd31f026-4f55-484b-bed1-8d3a9d1a1b70'),(24,'ARV Drug Supply for 3 Months','Current on ART clients who made visits in previous months (3 months ARV drug supply)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.NumericObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV Drug Supply for 3 Months\n Current on ART clients who made visits in previous months (3 months ARV drug supply)\n \n 2018-03-01 09:03:05 UTC\n \n 2018-03-01 18:15:05 UTC\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n 24\n ANY\n \n \n \n \n GREATER_EQUAL\n 90.0\n','2018-03-01 09:03:05',4,'2018-03-01 18:15:05',4,0,NULL,NULL,NULL,'96c4ce6b-436f-499e-9c07-9dedadc0f60e'),(25,'Tx. Curr. with visits in prev. 2 months and 2 months ARV Drug Supply','Current on ART clients who made visits in previous 2 months and ARV Drug Supply for 2 Months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Tx. Curr. with visits in prev. 2 months and 2 months ARV Drug Supply\n Current on ART clients who made visits in previous 2 months and ARV Drug Supply for 2 Months\n \n 2018-03-01 09:09:51 UTC\n \n 2018-03-01 18:16: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 25\n Current-on-ART-clients-who-made-visits-in-previous-2-months AND ARV-Drug-Supply-for-2-Months\n \n \n Current-on-ART-clients-who-made-visits-in-previous-2-months\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n \n \n \n ARV-Drug-Supply-for-2-Months\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n \n \n \n','2018-03-01 09:09:51',4,'2018-03-01 18:16:50',4,0,NULL,NULL,NULL,'796bd0e5-9af3-4536-9d6c-c80410cbede3'),(26,'Tx. Curr. with visits in prev. 3 months and 3 months ARV Drug Supply','Current on ART clients with visits in prev. 3 months and 3 months ARV Drug Supply','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Tx. Curr. with visits in prev. 3 months and 3 months ARV Drug Supply\n Current on ART clients with visits in prev. 3 months and 3 months ARV Drug Supply\n \n 2018-03-01 09:13:01 UTC\n \n 2018-03-01 18: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 26\n Current-on-ART-clients-who-made-visits-in-previous-3-months AND ARV-Drug-Supply-for-3-Months\n \n \n Current-on-ART-clients-who-made-visits-in-previous-3-months\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n \n \n \n ARV-Drug-Supply-for-3-Months\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n \n \n \n','2018-03-01 09:13:01',4,'2018-03-01 18:17:30',4,0,NULL,NULL,NULL,'963f27e9-75ea-42d0-8611-a66a3de9d6ab'),(27,'Tx. Curr. with visits in prev. 2 or 3 months and 2 or 3 months ARV Drug Supply','Current on ART clients with visits in prev. 2 or 3 months and 2 or 3 months ARV Drug Supply','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Tx. Curr. with visits in prev. 2 or 3 months and 2 or 3 months ARV Drug Supply\n Current on ART clients with visits in prev. 2 or 3 months and 2 or 3 months ARV Drug Supply\n \n 2018-03-01 09:17:02 UTC\n \n 2018-03-01 09:19: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 27\n Tx.-Curr.-with-visits-in-prev.-3-months-and-3-months-ARV-Drug-Supply OR Tx.-Curr.-with-visits-in-prev.-2-months-and-2-months-ARV-Drug-Supply\n \n \n Tx.-Curr.-with-visits-in-prev.-3-months-and-3-months-ARV-Drug-Supply\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 Tx.-Curr.-with-visits-in-prev.-2-months-and-2-months-ARV-Drug-Supply\n \n \n \n \n \n \n','2018-03-01 09:17:02',4,'2018-03-01 09:19:22',4,0,NULL,NULL,NULL,'7aaa2b3f-5eb7-45bc-93f7-8e22534e6f2d'),(28,'ART Summary (DSD)',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.LogicDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART Summary (DSD)\n \n 2018-03-01 09:42:19 UTC\n \n \n','2018-03-01 09:42:19',4,NULL,NULL,0,NULL,NULL,NULL,'3245fc9e-d4b6-46fb-9f14-b9f5db7ca56a'),(31,'ART patients transferred Into site','Transfer In for ART clients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART patients transferred Into site\n Transfer In for ART clients\n \n 2018-03-15 07:44:35 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 09:44:35',4,NULL,NULL,0,NULL,NULL,NULL,'5a9986bc-e592-4fbe-9c2d-67a68975be60'),(32,'ART patients transferred to other sites','Transfer out for ART patients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART patients transferred to other sites\n Transfer out for ART patients\n \n 2018-03-15 08:08:19 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 10:08:19',4,NULL,NULL,0,NULL,NULL,NULL,'0fe1183e-5cfd-4a12-bb33-915bd3212d52'),(33,'Date Restarted ART','Date ART was restarted after being stopped','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.DateObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Date Restarted ART\n Date ART was restarted after being stopped\n \n 2018-03-15 08:14:46 UTC\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n value1\n \n java.util.Date\n true\n \n \n value2\n \n java.util.Date\n true\n \n \n ANY\n \n \n \n \n GREATER_EQUAL\n LESS_EQUAL\n','2018-03-15 10:14:46',4,NULL,NULL,0,NULL,NULL,NULL,'19676fac-ac6b-4f91-a407-e179e74e9d27'),(34,'Children CD4 percent','Count the number of baseline CD4 percentages','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.NumericObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children CD4 percent\n Count the number of baseline CD4 percentages\n \n 2018-03-15 08:21:54 UTC\n \n 2018-03-15 08:35:26 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n 34\n ANY\n \n \n \n \n','2018-03-15 10:21:54',4,'2018-03-15 10:35:26',4,0,NULL,NULL,NULL,'c82c286a-90c2-44f4-8ce1-671df77529cd'),(35,'Adult CD4 Count','Return patient with a baseline CD4 counts','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.NumericObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Adult CD4 Count\n Return patient with a baseline CD4 counts\n \n 2018-03-15 08:26:07 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n','2018-03-15 10:26:07',4,NULL,NULL,0,NULL,NULL,NULL,'954ae31e-21d8-4ed6-8a4f-c9be726a5cf0'),(36,'New ART clients with baseline CD4 counts','New ART clients with baseline CD4 counts','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New ART clients with baseline CD4 counts\n New ART clients with baseline CD4 counts\n \n 2018-03-15 08:28:17 UTC\n \n 2018-03-15 08: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 36\n (Adult-CD4-Count OR Children-CD4-percent) AND ART-start-date\n \n \n Adult-CD4-Count\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n Children-CD4-percent\n \n \n \n \n \n \n ART-start-date\n \n \n \n \n locationList\n ${location}\n \n \n value2\n ${endDate}\n \n \n value1\n ${startDate}\n \n \n \n \n \n','2018-03-15 10:28:17',4,'2018-03-15 10:40:18',4,0,NULL,NULL,NULL,'b23434a0-ea24-4c1e-82e4-86fd50568241'),(37,'HIV care clients screened for TB','HIV care clients screened for TB','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HIV care clients screened for TB\n HIV care clients screened for TB\n \n 2018-03-15 13:41:45 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n \n \n','2018-03-15 15:41:45',4,NULL,NULL,0,NULL,NULL,NULL,'e74b63f9-655b-46fe-9397-29b07625ce61'),(38,'Presumptive TB case','Presumptive TB case- these are clients suspected for TB','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Presumptive TB case\n Presumptive TB case- these are clients suspected for TB\n \n 2018-03-15 13:47:06 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 15:47:06',4,NULL,NULL,0,NULL,NULL,NULL,'aa138e08-67c8-48bb-a54e-ce7ed7891547'),(41,'ARV regimen 1e TDF-3TC-NVP','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 1e TDF-3TC-NVP\n \n \n 2018-03-15 14:43:00 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 16:43:00',4,NULL,NULL,0,NULL,NULL,NULL,'f62bc2e5-0c7f-462a-bb28-ae0a6925c088'),(42,'ARV regimen 1f TDF-3TC-EFV','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 1f TDF-3TC-EFV\n \n \n 2018-03-15 14:44:30 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 16:44:30',4,NULL,NULL,0,NULL,NULL,NULL,'06693a67-bb3d-45d7-b9ba-a145d08bb974'),(43,'ARV regimen 1g ABC-3TC-NVP','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 1g ABC-3TC-NVP\n \n \n 2018-03-15 14:46:39 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 16:46:39',4,NULL,NULL,0,NULL,NULL,NULL,'4a1b3589-2ffd-493d-be4f-53a009ec903b'),(44,'ARV regimen 4b AZT-3TC-NVP','ARV regimen 4b AZT-3TC-NVP','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 4b AZT-3TC-NVP\n ARV regimen 4b AZT-3TC-NVP\n \n 2018-03-15 14:55:56 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 16:55:56',4,NULL,NULL,0,NULL,NULL,NULL,'f7ea0f19-995c-4563-b17a-5e0028fafb7b'),(45,'ARV regimen 1h ABC-3TC-EFV','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 1h ABC-3TC-EFV\n \n \n 2018-03-15 14:57:38 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 16:57:38',4,NULL,NULL,0,NULL,NULL,NULL,'99a80476-a4fa-4df3-be47-4dd669a8f34e'),(47,'ARV regimen 2d AZT-3TC-LPV/r','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 2d AZT-3TC-LPV/r\n \n \n 2018-03-15 15:02:27 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 17:02:27',4,NULL,NULL,0,NULL,NULL,NULL,'d03c0f54-dd1d-4fdd-9b52-d9b4ae023df6'),(48,'ARV regimen 2c TDF-3TC-LPV/r','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 2c TDF-3TC-LPV/r\n \n \n 2018-03-15 15:04:34 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 17:04:34',4,NULL,NULL,0,NULL,NULL,NULL,'46d6acb9-6e78-4194-bd7c-31b8894461cd'),(49,'ARV regimen 4d ABC-3TC-NVP','ARV regimen 4d ABC-3TC-NVP','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 4d ABC-3TC-NVP\n ARV regimen 4d ABC-3TC-NVP\n \n 2018-03-15 15:05:00 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 17:05:00',4,NULL,NULL,0,NULL,NULL,NULL,'84c300d3-4f0c-4861-b59f-7bd95b6250c1'),(50,'ARV regimen 2e TDF-3TC-ATV/r','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 2e TDF-3TC-ATV/r\n \n \n 2018-03-15 15:07:00 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 17:07:00',4,NULL,NULL,0,NULL,NULL,NULL,'3487cef8-a434-4bf5-93e3-d7b1d35de3b7'),(51,'ARV regimen 4c ABC-3TC-EFV','ARV regimen 4c ABC-3TC-EFV','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 4c ABC-3TC-EFV\n ARV regimen 4c ABC-3TC-EFV\n \n 2018-03-15 15:07:42 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 17:07:42',4,NULL,NULL,0,NULL,NULL,NULL,'44e9041e-b27a-4d4f-9dcb-61a4e6013818'),(52,'ARV regimen 2f AZT-3TC-ATV/r','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 2f AZT-3TC-ATV/r\n \n \n 2018-03-15 15:09:16 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 17:09:16',4,NULL,NULL,0,NULL,NULL,NULL,'03d90077-1768-4abb-a91e-4f2e80d5bab1'),(53,'ARV regimen 2g AZT-3TC-TDF-LPV/r','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 2g AZT-3TC-TDF-LPV/r\n \n \n 2018-03-15 15:12:02 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 17:12:02',4,NULL,NULL,0,NULL,NULL,NULL,'cbbbe740-93a5-4c78-81b4-998dc76bc27f'),(54,'ARV regimen 4a AZT-3TC-EFV','ARV regimen 4a AZT-3TC-EFV','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 4a AZT-3TC-EFV\n ARV regimen 4a AZT-3TC-EFV\n \n 2018-03-15 15:13:49 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 17:13:49',4,NULL,NULL,0,NULL,NULL,NULL,'29d5515c-bd24-40ac-8dad-048138385125'),(55,'ARV regimen 2g ABC-3TC-LPV/r','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 2g ABC-3TC-LPV/r\n \n \n 2018-03-15 15:16:19 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 17:16:19',4,NULL,NULL,0,NULL,NULL,NULL,'cf84777c-279b-4830-bfd3-c5ec1b424850'),(57,'ARV regimen 2h ABC-3TC-ATV/r','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 2h ABC-3TC-ATV/r\n \n \n 2018-03-15 15:17:46 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 17:17:46',4,NULL,NULL,0,NULL,NULL,NULL,'7f02425f-cf7d-469a-9655-d637938673ae'),(59,'ARV regimen 5b AZT-3TC-LPV/r','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 5b AZT-3TC-LPV/r\n \n \n 2018-03-15 15:20:34 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 17:20:34',4,NULL,NULL,0,NULL,NULL,NULL,'20b53122-3fa7-462d-82e3-f27f0ed30aa0'),(60,'ARV regimen 5a ABC-3TC-LPV/r','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 5a ABC-3TC-LPV/r\n \n \n 2018-03-15 15:22:30 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 17:22:30',4,NULL,NULL,0,NULL,NULL,NULL,'ffad5bd5-cc99-4a0c-9e2a-6fd312687894'),(61,'ARV Regimen 6a Ral-3TC-LPV/r','ARV Regimen 6a Ral-3TC-LPV/r','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV Regimen 6a Ral-3TC-LPV/r\n ARV Regimen 6a Ral-3TC-LPV/r\n \n 2018-03-15 15:22:41 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 17:22:41',4,NULL,NULL,0,NULL,NULL,NULL,'a4dfb5bf-0027-4631-b4f4-c08b481af363'),(62,'ARV regimen 3a Ral-3TC-LPV/r','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV regimen 3a Ral-3TC-LPV/r\n \n \n 2018-03-15 15:29:30 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 17:29:30',4,NULL,NULL,0,NULL,NULL,NULL,'52db4eec-2908-498f-a2fd-065b6eab6b50'),(63,'ARV Regimen 3b TDF-3TC-Ral-DRV/r','ARV Regimen 3b TDF-3TC-Ral-DRV/r','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV Regimen 3b TDF-3TC-Ral-DRV/r\n ARV Regimen 3b TDF-3TC-Ral-DRV/r\n \n 2018-03-15 15:30:20 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-03-15 17:30:20',4,NULL,NULL,0,NULL,NULL,NULL,'d0de30d5-9680-415c-a00d-ad9cc587616a'),(64,'CI04: Adults 1st Line ARV Regimen 1(c)AZT-3TC-NVP','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI04: Adults 1st Line ARV Regimen 1(c)AZT-3TC-NVP\n \n \n 2018-03-19 02:13:36 UTC\n \n 2019-01-10 19:00: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 64\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:13:36',4,'2019-01-10 19:00:35',4,0,NULL,NULL,NULL,'5891f5b4-bfe3-48cb-b782-6339f9d46ad6'),(65,'CI05: Adults 1st Line ARV Regimen 1(d)AZT-3TC-EFV','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI05: Adults 1st Line ARV Regimen 1(d)AZT-3TC-EFV\n \n \n 2018-03-19 02:17:34 UTC\n \n 2019-01-10 19:02: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 65\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:17:34',4,'2019-01-10 19:02:01',4,0,NULL,NULL,NULL,'19e9cc1b-0ffc-4415-84b6-a5b56edf5a23'),(66,'CI06: Adults 1st Line ARV Regimen 1(e)TDF-3TC-NVP','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI06: Adults 1st Line ARV Regimen 1(e)TDF-3TC-NVP\n \n \n 2018-03-19 02:19:37 UTC\n \n 2019-01-10 19:03: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 66\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:19:37',4,'2019-01-10 19:03:17',4,0,NULL,NULL,NULL,'302479e6-10a0-47c8-9931-21133317a576'),(67,'CI07: Adults 1st Line ARV Regimen 1(f)TDF-3TC-EFV','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI07: Adults 1st Line ARV Regimen 1(f)TDF-3TC-EFV\n \n \n 2018-03-19 02:21:35 UTC\n \n 2019-01-10 19:04: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 67\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:21:35',4,'2019-01-10 19:04:01',4,0,NULL,NULL,NULL,'1f6b7448-9557-4335-8d9c-3d1310626aa0'),(68,'CI08: Adults 1st Line ARV Regimen 1(g)ABC-3TC-NVP','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI08: Adults 1st Line ARV Regimen 1(g)ABC-3TC-NVP\n \n \n 2018-03-19 02:22:50 UTC\n \n 2019-01-10 19: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 68\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:22:50',4,'2019-01-10 19:05:20',4,0,NULL,NULL,NULL,'4a4a1d6a-5c08-451e-b63e-e590890bc6fc'),(69,'CI09: Adults 1st Line ARV Regimen 1(h)ABC-3TC-EFV','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI09: Adults 1st Line ARV Regimen 1(h)ABC-3TC-EFV\n \n \n 2018-03-19 02:24:03 UTC\n \n 2019-01-10 19:06: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 69\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:24:03',4,'2019-01-10 19:06:22',4,0,NULL,NULL,NULL,'e1a6903f-5c76-4d1f-85cb-561bc2a1ea1e'),(70,'CI09: Children 1st Line ARV Regimen 4(c)AZT-3TC-NVP','4(c)AZT-3TC-NVP','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI09: Children 1st Line ARV Regimen 4(c)AZT-3TC-NVP\n 4(c)AZT-3TC-NVP\n \n 2018-03-19 02:26:02 UTC\n \n 2019-02-08 07:20: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 70\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:26:02',4,'2019-02-08 07:20:57',4,0,NULL,NULL,NULL,'b92c628d-b93e-40aa-a5d0-c8f354ab12c9'),(71,'CI10: Children 1st Line ARV Regimen 4(d)AZT-3TC-EFV','4(d)AZT-3TC-EFV','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI10: Children 1st Line ARV Regimen 4(d)AZT-3TC-EFV\n 4(d)AZT-3TC-EFV\n \n 2018-03-19 02:27:41 UTC\n \n 2019-02-08 07:29: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 71\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:27:41',4,'2019-02-08 07:29:58',4,0,NULL,NULL,NULL,'5401502e-24d3-4a01-85c9-f8389c59b566'),(72,'CI11: Children 1st Line ARV Regimen 4(e)ABC-3TC-NVP','4(e)ABC-3TC-NVP','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI11: Children 1st Line ARV Regimen 4(e)ABC-3TC-NVP\n 4(e)ABC-3TC-NVP\n \n 2018-03-19 02:29:03 UTC\n \n 2019-02-08 07:32: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 72\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:29:03',4,'2019-02-08 07:32:26',4,0,NULL,NULL,NULL,'183a5f26-6f97-427c-9409-d6263e015aab'),(73,'CI12: Children 1st Line ARV Regimen 4(f)ABC-3TC-EFV','4(f)ABC-3TC-EFV','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI12: Children 1st Line ARV Regimen 4(f)ABC-3TC-EFV\n 4(f)ABC-3TC-EFV\n \n 2018-03-19 02:30:25 UTC\n \n 2019-02-08 07:34: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 73\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:30:25',4,'2019-02-08 07:34:32',4,0,NULL,NULL,NULL,'d84fd2f9-951d-4bbc-b6fc-f59b71dbba6b'),(74,'CI13: Adult 2nd Line ARV Regimen 2(d)TDF-3TC-LPV/r','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI13: Adult 2nd Line ARV Regimen 2(d)TDF-3TC-LPV/r\n \n \n 2018-03-19 02:32:22 UTC\n \n 2019-04-04 06:51: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 74\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:32:22',4,'2019-04-04 06:51:57',4,0,NULL,NULL,NULL,'20bdcee4-fe92-4457-a041-6db72def1895'),(75,'CI14: Adult 2nd Line ARV Regimen 2(c)AZT-3TC-LPV/r','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI14: Adult 2nd Line ARV Regimen 2(c)AZT-3TC-LPV/r\n \n \n 2018-03-19 02:33:44 UTC\n \n 2019-04-04 06:50: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 75\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:33:44',4,'2019-04-04 06:50:57',4,0,NULL,NULL,NULL,'998aa33c-d34b-438a-b4c4-c2dbe25aa481'),(76,'CI15: Adult 2nd Line ARV Regimen 2(e)AZT-3TC-ATV/r','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI15: Adult 2nd Line ARV Regimen 2(e)AZT-3TC-ATV/r\n \n \n 2018-03-19 02:35:46 UTC\n \n 2019-04-04 06: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 76\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:35:46',4,'2019-04-04 06:53:03',4,0,NULL,NULL,NULL,'78ffec82-cb3a-49ad-aaa2-1f50bfe12e80'),(77,'CI16: Adult 2nd Line ARV Regimen 2(f)TDF-3TC-ATV/r','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI16: Adult 2nd Line ARV Regimen 2(f)TDF-3TC-ATV/r\n \n \n 2018-03-19 02:36:59 UTC\n \n 2019-04-04 06:53: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 77\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:36:59',4,'2019-04-04 06:53:58',4,0,NULL,NULL,NULL,'f5c9b6ce-13e2-4305-b991-045536fd153e'),(78,'CI17: Adult 2nd Line ARV Regimen 2(g)AZT-3TC-TDF-LPV/r','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI17: Adult 2nd Line ARV Regimen 2(g)AZT-3TC-TDF-LPV/r\n \n \n 2018-03-19 02:38:02 UTC\n \n 2018-03-19 02: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 78\n COUNT\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n','2018-03-19 04:38:02',4,'2018-03-19 04:42:22',4,0,NULL,NULL,NULL,'00a49e20-9f14-437e-a4cd-857ae281e238'),(79,'CI18: Adults 2nd Line ARV Regimen 2(g) ABC-3TC-LPV/r','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI18: Adults 2nd Line ARV Regimen 2(g) ABC-3TC-LPV/r\n \n \n 2018-03-19 02:40:22 UTC\n \n 2019-01-10 19: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 79\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:40:22',4,'2019-01-10 19:18:05',4,0,NULL,NULL,NULL,'8b70c3a8-a114-4ace-a458-9677150c48e2'),(80,'CI19: Adults 2nd Line ARV Regimen 2(h) ABC-3TC-ATV/r','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI19: Adults 2nd Line ARV Regimen 2(h) ABC-3TC-ATV/r\n \n \n 2018-03-19 02:43:15 UTC\n \n 2019-01-10 19:19: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 80\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:43:15',4,'2019-01-10 19:19:12',4,0,NULL,NULL,NULL,'11e7ab47-8ee4-4bbb-8199-32619d304e32'),(81,'CI20: Adults 3rd Line ARV Regimen 3(a) Ral-3TC-LPV/r','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI20: Adults 3rd Line ARV Regimen 3(a) Ral-3TC-LPV/r\n \n \n 2018-03-19 02:45:12 UTC\n \n 2019-01-10 19:20: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 81\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:45:12',4,'2019-01-10 19:20:10',4,0,NULL,NULL,NULL,'e22a68da-5893-42c3-b261-1b0e0a5a98aa'),(82,'CI21: Adults 3rd Line ARV Regimen 3(b) TDF/3TC/Ral/DRV/r','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI21: Adults 3rd Line ARV Regimen 3(b) TDF/3TC/Ral/DRV/r\n \n \n 2018-03-19 02:46:35 UTC\n \n 2019-01-10 19: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 82\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:46:35',4,'2019-01-10 19:21:13',4,0,NULL,NULL,NULL,'5b189710-2a56-477b-b2d4-569b7a16a30f'),(83,'CI22: Adults and Children 3rd Line ARV Regimen 3(c)EFV-DRV/r-Ral','replaced 6(a) ETV DRV/r/ral must ahve been a typo error','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI22: Adults and Children 3rd Line ARV Regimen 3(c)EFV-DRV/r-Ral\n replaced 6(a) ETV DRV/r/ral must ahve been a typo error\n \n 2018-03-19 02:48:05 UTC\n \n 2019-02-21 09:31: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 83\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:48:05',4,'2019-02-21 09:31:19',4,0,NULL,NULL,NULL,'51510b74-2bad-4e95-8a68-7211097e16b2'),(84,'CI23: Children 2nd Line ARV Regimen 5(a)AZT-3TC-LPV/r','5(a)AZT-3TC-LPV/r','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI23: Children 2nd Line ARV Regimen 5(a)AZT-3TC-LPV/r\n 5(a)AZT-3TC-LPV/r\n \n 2018-03-19 02:49:37 UTC\n \n 2019-04-04 09:44: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 84\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:49:37',4,'2019-04-04 09:44:35',4,0,NULL,NULL,NULL,'cd5977ea-be20-4b8c-af53-2dd17d4b771b'),(85,'CI24: Children 2nd Line ARV Regimen 5(b)ABC-3TC-LPV/r','5(b)ABC-3TC-LPV/r','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI24: Children 2nd Line ARV Regimen 5(b)ABC-3TC-LPV/r\n 5(b)ABC-3TC-LPV/r\n \n 2018-03-19 02:50:49 UTC\n \n 2019-04-04 09:45: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 85\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:50:49',4,'2019-04-04 09:45:40',4,0,NULL,NULL,NULL,'c9fca87c-8069-49ef-b8fd-aae5f6ab4de8'),(86,'CI25: Children 3rd Line ARV Regimen 6(a) Ral-3TC-LPV/r','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI25: Children 3rd Line ARV Regimen 6(a) Ral-3TC-LPV/r\n \n \n 2018-03-19 02:52:07 UTC\n \n 2019-02-08 08: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 86\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:52:07',4,'2019-02-08 08:05:17',4,0,NULL,NULL,NULL,'b7afeb4d-f5f6-49fc-bf16-b65fa53f485a'),(87,'CI26: ART Transfer Ins','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI26: ART Transfer Ins\n \n \n 2018-03-19 02:53:56 UTC\n \n 2019-01-31 18:12: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 87\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:53:56',4,'2019-01-31 18:12:52',4,0,NULL,NULL,NULL,'d31412f8-9a7a-46d8-9f2e-7c51ed7f2057'),(88,'CI27: ART Transfer Outs','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI27: ART Transfer Outs\n \n \n 2018-03-19 02:55:42 UTC\n \n 2019-01-31 18:11: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 88\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:55:42',4,'2019-01-31 18:11:39',4,0,NULL,NULL,NULL,'939c91e7-c164-456f-a4dc-4da80bacc4b3'),(89,'CI28: Client who Restarted ART','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI28: Client who Restarted ART\n \n \n 2018-03-19 02:57:34 UTC\n \n 2019-01-31 18:08: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 89\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 02:57:34',4,'2019-01-31 18:08:06',4,0,NULL,NULL,NULL,'65cd06c4-31ed-4a82-a6a4-02e217b1e0ba'),(90,'CI29: New ART clients with baseline CD4+ counts','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI29: New ART clients with baseline CD4+ counts\n \n \n 2018-03-19 03:00:05 UTC\n \n 2018-03-19 03:01: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 90\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 05:00:05',4,'2018-03-19 05:01:21',4,0,NULL,NULL,NULL,'bf36f124-d930-431e-b22a-fd0d7f7353c4'),(91,'CI30: HIV Care clients screened for TB','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI30: HIV Care clients screened for TB\n \n \n 2018-03-19 03:03:31 UTC\n \n 2019-02-03 09:56: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 91\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 03:03:31',4,'2019-02-03 09:56:53',4,0,NULL,NULL,NULL,'47456755-c716-4eab-b686-c9d372ea7468'),(92,'CI31: Presumptive TB HIV Care cases','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI31: Presumptive TB HIV Care cases\n \n \n 2018-03-19 03:06:01 UTC\n \n 2019-02-03 09: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 92\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-19 03:06:01',4,'2019-02-03 09:58:15',4,0,NULL,NULL,NULL,'cd4971f7-81a7-45f8-b49b-9de683d0c8d3'),(94,'Date confirmed HIV Positive test','Date confirmed HIV+ test','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.DateObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Date confirmed HIV Positive test\n Date confirmed HIV+ test\n \n 2018-03-20 14:23:54 UTC\n \n 2018-03-20 14:33:43 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n 94\n ANY\n \n \n \n \n','2018-03-20 16:23:54',4,'2018-03-20 16:33:43',4,0,NULL,NULL,NULL,'c62c2f3b-3f3e-442b-beab-c25809316b25'),(95,'Date enrolled in Pre-ART','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.DateObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Date enrolled in Pre-ART\n \n \n 2018-03-20 14:25:52 UTC\n \n 2019-01-23 08:27:20 UTC\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n value1\n \n java.util.Date\n true\n \n \n value2\n \n java.util.Date\n true\n \n \n 95\n ANY\n \n \n \n \n GREATER_EQUAL\n LESS_EQUAL\n','2018-03-20 16:25:52',4,'2019-01-23 10:27:20',4,0,NULL,NULL,NULL,'d785b586-bd07-4359-b733-54968416b764'),(97,'Clients newly diagnosed and enrolled into HIV Care/Pre-ART','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly diagnosed and enrolled into HIV Care/Pre-ART\n \n \n 2018-03-20 14:36:25 UTC\n \n 2019-01-31 20:12: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 97\n PreART-Clients-not-initiated-on-ART AND Date-Confirmed-HIV-positive-SQL\n \n \n PreART-Clients-not-initiated-on-ART\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n \n \n \n Date-Confirmed-HIV-positive-SQL\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','2018-03-20 14:36:25',4,'2019-01-31 20:12:16',4,0,NULL,NULL,NULL,'77c109da-808a-4a26-8e7f-41839ab40574'),(98,'CI32: Clients newly diagnosed and started on Pre-ART','Clients newly diagnosed and started on HIV Care','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI32: Clients newly diagnosed and started on Pre-ART\n Clients newly diagnosed and started on HIV Care\n \n 2018-03-22 08:48:54 UTC\n \n 2019-02-04 08:17: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 98\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-22 08:48:54',4,'2019-02-04 08:17:38',4,0,NULL,NULL,NULL,'05e583fe-4a8b-4359-8ac8-8df7f02f8e96'),(99,'CI33: Clients Started on Pre-ART','Clients Started on HIV Care','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI33: Clients Started on Pre-ART\n Clients Started on HIV Care\n \n 2018-03-22 08:48:55 UTC\n \n 2019-02-04 08:21: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 99\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-22 08:48:55',4,'2019-02-04 08:21:41',4,0,NULL,NULL,NULL,'6ba04297-1210-4d0e-8728-0ac24c4b0a3a'),(100,'PIR02: Pre-ART Report','Reports all Pre-ART or Current in HIV Care indicators into DHIS2 i.e. Newly enrolled, Current in HIV Care etc. ','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR02: Pre-ART Report\n Reports all Pre-ART or Current in HIV Care indicators into DHIS2 i.e. Newly enrolled, Current in HIV Care etc. \n \n 2018-03-27 08:30:37 UTC\n \n 2018-03-27 08: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 100\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','2018-03-27 10:30:37',4,'2018-03-27 10:31:03',4,0,NULL,NULL,NULL,'5b3a4b6f-1584-43c0-a3cb-7973270912f2'),(101,'PIR02: Pre-ART 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 PIR02: Pre-ART Report Data Set\n \n 2018-03-27 08:30:38 UTC\n \n 2019-03-11 12:08: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 101\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age_DATE\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n DM_Age\n \n \n \n \n \n \n \n \n CnPrF10-14\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_DATE\n 10to14yrs\n \n \n \n \n \n CnPrF15-19\n \n \n \n \n \n \n CnPrF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n 20to24yrs\n \n \n \n \n \n CnPrF25-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n 25to49yrs\n \n \n \n \n \n CnPrM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n 10to14yrs\n \n \n \n \n \n CnPrM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n 15to19yrs\n \n \n \n \n \n CnPrM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n 20to24yrs\n \n \n \n \n \n CnPrM25-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n 25to49yrs\n \n \n \n \n \n CnPreF1-4\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n 01to04yrs\n \n \n \n \n \n CnPreF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n 05to09yrs\n \n \n \n \n \n CnPreF50+\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n 50+yrs\n \n \n \n \n \n CnPreFU1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n Under 1yr\n \n \n \n \n \n CnPreM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n 01to04yrs\n \n \n \n \n \n CnPreM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n 05to09yrs\n \n \n \n \n \n CnPreM50+\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n 50+yrs\n \n \n \n \n \n CnPreMU1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n Under 1yr\n \n \n \n \n \n NuPrF10-14\n \n \n \n \n \n \n \n \n \n NuPrF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n 15to19yrs\n \n \n \n \n \n NuPrF20-24\n \n \n \n \n \n \n NuPrF25-49\n \n \n \n \n \n \n NuPrM10-14\n \n \n \n \n \n \n NuPrM15-19\n \n \n \n \n \n \n NuPrM20-24\n \n \n \n \n \n \n NuPrM25-49\n \n \n \n \n \n \n NuPreF1-4\n \n \n \n \n \n \n NuPreF5-9\n \n \n \n \n \n \n NuPreF50+\n \n \n \n \n \n \n NuPreFU1\n \n \n \n \n \n \n NuPreM1-4\n \n \n \n \n \n \n NuPreM5-9\n \n \n \n \n \n \n NuPreM50+\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 50+yrs\n \n \n \n \n \n NuPreMU1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n PreMF1-4\n \n \n \n \n \n \n \n \n \n PreMF10-14\n \n \n \n \n \n \n PreMF15-19\n \n \n \n \n \n \n PreMF20-24\n \n \n \n \n \n \n PreMF25-49\n \n \n \n \n \n \n PreMF5-9\n \n \n \n \n \n \n PreMF50+\n \n \n \n \n \n \n PreMFU1\n \n \n \n \n \n \n PreMM1-4\n \n \n \n \n \n \n PreMM10-14\n \n \n \n \n \n \n PreMM15-19\n \n \n \n \n \n \n PreMM20-24\n \n \n \n \n \n \n PreMM25-49\n \n \n \n \n \n \n PreMM5-9\n \n \n \n \n \n \n PreMM50+\n \n \n \n \n \n \n PreMMU1\n \n \n \n \n \n \n StaPF10-14\n \n \n \n \n \n \n \n \n \n StaPF15-19\n \n \n \n \n \n \n StaPF20-24\n \n \n \n \n \n \n StaPF25-49\n \n \n \n \n \n \n StaPM10-14\n \n \n \n \n \n \n StaPM15-19\n \n \n \n \n \n \n StaPM20-24\n \n \n \n \n \n \n StaPM25-49\n \n \n \n \n \n \n StaPreF1-4\n \n \n \n \n \n \n StaPreF5-9\n \n \n \n \n \n \n StaPreFU1\n \n \n \n \n \n \n StaPreM1-4\n \n \n \n \n \n \n StaPreM5-9\n \n \n \n \n \n \n StaPreM50+\n \n \n \n \n \n \n StaPreMU1\n \n \n \n \n \n \n','2018-03-27 08:30:38',4,'2019-03-11 12:08:33',4,0,NULL,NULL,NULL,'4cc67faa-d329-4188-95ac-8a6b0e61cbee'),(104,'PIR03: 5. ARV Regimen at end of every month Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR03: 5. ARV Regimen at end of every month Data Set\n \n 2018-03-27 13:44:01 UTC\n \n 2019-04-26 08:21: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 104\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n \n \n DM_Weight_Updated\n \n \n \n \n \n \n \n \n 1cAdultF\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 1cAdultM\n \n \n \n \n DM_Sex\n Males\n \n \n \n \n \n 1dAdultF\n \n \n \n \n \n \n \n \n \n 1dAdultM\n \n \n \n \n \n \n 1eAdultF\n \n \n \n \n \n \n \n \n \n 1eAdultM\n \n \n \n \n \n \n 1fAdultF\n \n \n \n \n \n \n \n \n \n 1fAdultM\n \n \n \n \n \n \n 1gAdultF\n \n \n \n \n \n \n \n \n \n 1gAdultM\n \n \n \n \n \n \n 1hAdultF\n \n \n \n \n \n \n \n \n \n 1hAdultM\n \n \n \n \n \n \n 1st4c13.9F\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Weight_Updated\n 10to13.9kg\n \n \n \n \n \n 1st4c13.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Weight_Updated\n 10to13.9kg\n \n \n \n \n \n 1st4c19.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Weight_Updated\n 14to19.9kg\n \n \n \n \n \n 1st4c19.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Weight_Updated\n 14to19.9kg\n \n \n \n \n \n 1st4c24.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Weight_Updated\n 20to24.9kg\n \n \n \n \n \n 1st4c24.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Weight_Updated\n 20to24.9kg\n \n \n \n \n \n 1st4c25F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Weight_Updated\n 25+kg\n \n \n \n \n \n 1st4c25M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Weight_Updated\n 25+kg\n \n \n \n \n \n 1st4c3.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Weight_Updated\n 03to3.9kg\n \n \n \n \n \n 1st4c3.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Weight_Updated\n 03to3.9kg\n \n \n \n \n \n 1st4c5.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Weight_Updated\n 04to5.9kg\n \n \n \n \n \n 1st4c5.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Weight_Updated\n 04to5.9kg\n \n \n \n \n \n 1st4c9.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Weight_Updated\n 06to9.9kg\n \n \n \n \n \n 1st4c9.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Weight_Updated\n 06to9.9kg\n \n \n \n \n \n 1st4d13.9F\n \n \n \n \n \n \n \n \n \n 1st4d13.9M\n \n \n \n \n \n \n 1st4d19.9F\n \n \n \n \n \n \n 1st4d19.9M\n \n \n \n \n \n \n 1st4d24.9F\n \n \n \n \n \n \n 1st4d24.9M\n \n \n \n \n \n \n 1st4d25F\n \n \n \n \n \n \n 1st4d25M\n \n \n \n \n \n \n 1st4d3.9F\n \n \n \n \n \n \n 1st4d3.9M\n \n \n \n \n \n \n 1st4d5.9F\n \n \n \n \n \n \n 1st4d5.9M\n \n \n \n \n \n \n 1st4d9.9F\n \n \n \n \n \n \n 1st4d9.9M\n \n \n \n \n \n \n 4e10-13.9F\n \n \n \n \n \n \n \n \n \n 4e10-13.9M\n \n \n \n \n \n \n 4e14-19.9F\n \n \n \n \n \n \n 4e14-19.9M\n \n \n \n \n \n \n 4e20-24.9F\n \n \n \n \n \n \n 4e20-24.9M\n \n \n \n \n \n \n 4e25+F\n \n \n \n \n \n \n 4e25+M\n \n \n \n \n \n \n 4e3-3.9F\n \n \n \n \n \n \n 4e3-3.9M\n \n \n \n \n \n \n 4e4-5.9F\n \n \n \n \n \n \n 4e4-5.9M\n \n \n \n \n \n \n 4e6-9.9F\n \n \n \n \n \n \n 4e6-9.9M\n \n \n \n \n \n \n 4f10-13.9F\n \n \n \n \n \n \n \n \n \n 4f10-13.9M\n \n \n \n \n \n \n 4f14-19.9F\n \n \n \n \n \n \n 4f14-19.9M\n \n \n \n \n \n \n 4f20-24.9F\n \n \n \n \n \n \n 4f20-24.9M\n \n \n \n \n \n \n 4f25+F\n \n \n \n \n \n \n 4f25+M\n \n \n \n \n \n \n 4f3-3.9F\n \n \n \n \n \n \n 4f3-3.9M\n \n \n \n \n \n \n 4f4-5.9F\n \n \n \n \n \n \n 4f4-5.9M\n \n \n \n \n \n \n 4f6-9.9F\n \n \n \n \n \n \n 4f6-9.9M\n \n \n \n \n \n \n','2018-03-27 13:44:01',4,'2019-04-26 08:21:29',4,0,NULL,NULL,NULL,'3b30ec64-f372-4307-9988-e169bd149057'),(106,'PIR04: 4. ARV Regimen at end of month (2nd Line Adults and Children) Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR04: 4. ARV Regimen at end of month (2nd Line Adults and Children) Data Set\n \n 2018-03-27 13:48:07 UTC\n \n 2019-04-29 14:42: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 106\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n \n \n DM_Weight_Updated\n \n \n \n \n \n \n \n \n 2cAdultF\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 2cAdultM\n \n \n \n \n DM_Sex\n Males\n \n \n \n \n \n 2dAdultF\n \n \n \n \n \n \n \n \n \n 2dAdultM\n \n \n \n \n \n \n 2eAdultF\n \n \n \n \n \n \n \n \n \n 2eAdultM\n \n \n \n \n \n \n 2fAdultF\n \n \n \n \n \n \n \n \n \n 2fAdultM\n \n \n \n \n \n \n 2gBCAdultF\n \n \n \n \n \n \n \n \n \n 2gBCAdultM\n \n \n \n \n \n \n 2hAdultF\n \n \n \n \n \n \n \n \n \n 2hAdultM\n \n \n \n \n \n \n 5a10-13.9F\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 10to13.9kg\n \n \n \n \n \n 5a10-13.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 10to13.9kg\n \n \n \n \n \n 5a14-19.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 14to19.9kg\n \n \n \n \n \n 5a14-19.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 14to19.9kg\n \n \n \n \n \n 5a20-24.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 20to24.9kg\n \n \n \n \n \n 5a20-24.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 20to24.9kg\n \n \n \n \n \n 5a25+F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 25+kg\n \n \n \n \n \n 5a25+M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 25+kg\n \n \n \n \n \n 5a3-3.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 03to3.9kg\n \n \n \n \n \n 5a3-3.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 03to3.9kg\n \n \n \n \n \n 5a4-5.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 04to5.9kg\n \n \n \n \n \n 5a4-5.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 04to5.9kg\n \n \n \n \n \n 5a6-9.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 06to9.9kg\n \n \n \n \n \n 5a6-9.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 06to9.9kg\n \n \n \n \n \n 5b10-13.9F\n \n \n \n \n \n \n \n \n \n 5b10-13.9M\n \n \n \n \n \n \n 5b14-19.9F\n \n \n \n \n \n \n 5b14-19.9M\n \n \n \n \n \n \n 5b20-24.9F\n \n \n \n \n \n \n 5b20-24.9M\n \n \n \n \n \n \n 5b25+F\n \n \n \n \n \n \n 5b25+M\n \n \n \n \n \n \n 5b3-3.9F\n \n \n \n \n \n \n 5b3-3.9M\n \n \n \n \n \n \n 5b4-5.9F\n \n \n \n \n \n \n 5b4-5.9M\n \n \n \n \n \n \n 5b6-9.9F\n \n \n \n \n \n \n 5b6-9.9M\n \n \n \n \n \n \n','2018-03-27 13:48:07',4,'2019-04-29 14:42:44',4,0,NULL,NULL,NULL,'8d27c88e-c64d-41d1-93ac-09194a43b8c6'),(107,'All clients ever enrolled in Pre-ART','Uses the Date Enrolled in HIV Care concept to check if there are any observation of this concept before today\'s date','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.DateObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All clients ever enrolled in Pre-ART\n Uses the Date Enrolled in HIV Care concept to check if there are any observation of this concept before today's date\n \n 2018-03-28 07:47:30 UTC\n \n 2018-03-28 07:49:38 UTC\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n 107\n ANY\n \n \n \n \n','2018-03-28 09:47:30',4,'2018-03-28 09:49:38',4,0,NULL,NULL,NULL,'b29f40a8-f100-43d2-a841-753081556358'),(108,'Clients not initiated on ART','This cohort query is used in conjunction with the Clients ever enrolled on Pre-ART query to select only those who are not initiated on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.DateObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients not initiated on ART\n This cohort query is used in conjunction with the Clients ever enrolled on Pre-ART query to select only those who are not initiated on ART\n \n 2018-03-28 08:00:39 UTC\n \n 2019-01-22 14:26:10 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n 108\n NO\n \n \n \n \n','2018-03-28 10:00:39',4,'2019-01-22 16:26:10',4,0,NULL,NULL,NULL,'e9fa623d-a779-4533-a4b2-26b701863195'),(109,'Clients currently enrolled on Pre-ART','Client currently on Pre-ART and not Started on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients currently enrolled on Pre-ART\n Client currently on Pre-ART and not Started on ART\n \n 2018-03-28 08:04:27 UTC\n \n 2019-01-31 19:53:17 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 109\n All-clients-ever-enrolled-in-Pre-ART AND Clients-not-initiated-on-ART-SQL-Query-Version\n \n \n All-clients-ever-enrolled-in-Pre-ART\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n \n \n \n Clients-not-initiated-on-ART-SQL-Query-Version\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n \n \n \n','2018-03-28 08:04:27',4,'2019-01-31 19:53:17',4,0,NULL,NULL,NULL,'74a0a573-ec85-4624-80e7-f4b4fb69155b'),(110,'Current in Pre-ART clients Seen for Revisits','Current in HIV Care clients SEEN for revisits this month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Current in Pre-ART clients Seen for Revisits\n Current in HIV Care clients SEEN for revisits this month\n \n 2018-03-28 08:43:12 UTC\n \n 2019-01-24 13:44: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 110\n PreART-Clients-not-initiated-on-ART AND Clients-seen\n \n \n PreART-Clients-not-initiated-on-ART\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n \n \n \n Clients-seen\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n','2018-03-28 08:43:12',4,'2019-01-24 13:44:00',4,0,NULL,NULL,NULL,'12070eb5-96e0-4684-b71f-c0e1f7b88bcd'),(111,'PIR05: ART Report','Reports all Current in ART indicators into DHIS2 i.e. Newly Initiated, Current in ART etc.','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR05: ART Report\n Reports all Current in ART indicators into DHIS2 i.e. Newly Initiated, Current in ART etc.\n \n 2018-03-28 09:05:07 UTC\n \n 2018-03-28 09:08: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 111\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','2018-03-28 11:05:07',4,'2018-03-28 11:08:08',4,0,NULL,NULL,NULL,'5e05f218-9849-4e55-8c1c-e3d02422227c'),(112,'ART 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 ART Report Data Set\n \n 2018-03-28 09:05:08 UTC\n \n 2019-03-26 13:07: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 112\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age_DATE\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n Discordant\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 NuStF10-14\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n 10to14yrs\n \n \n \n \n \n NuStF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n 15to19yrs\n \n \n \n \n \n NuStF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n 20to24yrs\n \n \n \n \n \n NuStF25-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n 25to49yrs\n \n \n \n \n \n NuStM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n 10to14yrs\n \n \n \n \n \n NuStM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n 15to19yrs\n \n \n \n \n \n NuStM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n 20to24yrs\n \n \n \n \n \n NuStM25-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n 25to49yrs\n \n \n \n \n \n NuStatF1-4\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n 01to04yrs\n \n \n \n \n \n NuStatF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n 05to09yrs\n \n \n \n \n \n NuStatF50\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n 50+yrs\n \n \n \n \n \n NuStatFU1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n Under 1yr\n \n \n \n \n \n NuStatM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n 01to04yrs\n \n \n \n \n \n NuStatM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n 05to09yrs\n \n \n \n \n \n NuStatM50\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n 50+yrs\n \n \n \n \n \n NustatMU1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n Under 1yr\n \n \n \n \n \n RestartAll\n \n \n \n \n \n \n \n \n \n SeenF1-4\n \n \n \n \n \n \n \n \n \n SeenF10-14\n \n \n \n \n \n \n SeenF15-19\n \n \n \n \n \n \n SeenF20-24\n \n \n \n \n \n \n SeenF25-49\n \n \n \n \n \n \n SeenF5-9\n \n \n \n \n \n \n SeenF50\n \n \n \n \n \n \n SeenFU1\n \n \n \n \n \n \n SeenM1-4\n \n \n \n \n \n \n SeenM10-14\n \n \n \n \n \n \n SeenM15-19\n \n \n \n \n \n \n SeenM20-24\n \n \n \n \n \n \n SeenM25-49\n \n \n \n \n \n \n SeenM5-9\n \n \n \n \n \n \n SeenM50\n \n \n \n \n \n \n SeenMU1\n \n \n \n \n \n \n TranOutAll\n \n \n \n \n \n \n \n \n \n TransInAll\n \n \n \n \n \n \n \n \n \n TxPrF15-19\n \n \n \n \n \n \n \n \n \n TxPrF20-24\n \n \n \n \n \n \n TxPrF25-49\n \n \n \n \n \n \n TxPrM10-14\n \n \n \n \n \n \n TxPrM15-19\n \n \n \n \n \n \n TxPrM20-24\n \n \n \n \n \n \n TxPrM25-49\n \n \n \n \n \n \n TxPreF1-4\n \n \n \n \n \n \n TxPreF5-9\n \n \n \n \n \n \n TxPreF50\n \n \n \n \n \n \n TxPreFU1\n \n \n \n \n \n \n TxPreM1-4\n \n \n \n \n \n \n TxPreM5-9\n \n \n \n \n \n \n TxPreM50\n \n \n \n \n \n \n TxPreMU1\n \n \n \n \n \n \n TxprF10-14\n \n \n \n \n \n \n baseCD4All\n \n \n \n \n \n \n \n \n \n','2018-03-28 09:05:08',4,'2019-03-26 13:07:32',4,0,NULL,NULL,NULL,'6618a6b4-5678-4525-9785-0ae3abf0eb41'),(113,'Clients ever enrolled in Pre-ART and seen in previous 1 or 2 months','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients ever enrolled in Pre-ART and seen in previous 1 or 2 months\n \n \n 2018-03-28 10:13:44 UTC\n \n 2019-01-24 13:19:29 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n 113\n select distinct person_id \nfrom obs o \nwhere location_id =:location \nand o.concept_id = 2223 \nand (MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) OR \nMONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH))) \nand person_id not in ( \n select distinct person_id \n from obs os \n where os.location_id =:location \n and (os.concept_id = 3843 and os.value_coded = 3842) \n and MONTH(os.obs_datetime) = MONTH(DATE(:endDate)) \n and YEAR(os.obs_datetime) = YEAR(DATE(:endDate)) \n )\n','2018-03-28 10:13:44',4,'2019-01-24 13:19:29',4,0,NULL,NULL,NULL,'0d2bc33a-007b-4c9b-a6be-439f126f3c27'),(115,'ARV Regimen at end of month (3rd Line Adults and Children) Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV Regimen at end of month (3rd Line Adults and Children) Data Set\n \n 2018-03-28 10:34:02 UTC\n \n 2019-03-20 14:13: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 115\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n \n \n DM_Weight_Updated\n \n \n \n \n \n \n \n \n 3aAdultF\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 Adults\n \n \n \n \n \n 3aAdultM\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Adults\n \n \n \n \n \n 3bAdultF\n \n \n \n \n \n \n \n \n \n 3bAdultM\n \n \n \n \n \n \n 3cAdultF\n \n \n \n \n \n \n \n \n \n 3cAdultM\n \n \n \n \n \n \n 6a10-13.9F\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 10to13.9kg\n \n \n \n \n \n 6a10-13.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 10to13.9kg\n \n \n \n \n \n 6a14-19.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 14to19.9kg\n \n \n \n \n \n 6a14-19.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 14to19.9kg\n \n \n \n \n \n 6a20-24.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 20to24.9kg\n \n \n \n \n \n 6a20-24.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 20to24.9kg\n \n \n \n \n \n 6a25+F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 25+kg\n \n \n \n \n \n 6a25+M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 25+kg\n \n \n \n \n \n 6a3-3.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 03to3.9kg\n \n \n \n \n \n 6a3-3.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 03to3.9kg\n \n \n \n \n \n 6a4-5.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 04to5.9kg\n \n \n \n \n \n 6a4-5.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 04to5.9kg\n \n \n \n \n \n 6a6-9.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 06to9.9kg\n \n \n \n \n \n 6a6-9.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 06to9.9kg\n \n \n \n \n \n','2018-03-28 10:34:02',4,'2019-03-20 14:13:11',4,0,NULL,NULL,NULL,'f623aaa7-e30a-4eac-9853-704b715fd1c5'),(116,'Current in Pre-ART clients seen in previous months','Current in Pre-ART clients seen in previous months, but not seen this current month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Current in Pre-ART clients seen in previous months\n Current in Pre-ART clients seen in previous months, but not seen this current month\n \n 2018-03-28 10:39:06 UTC\n \n 2019-01-24 13:49: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 116\n PreART-Clients-not-initiated-on-ART AND Clients-enrolled-in-Pre-ART-and-seen-in-previous-1-or-2-months\n \n \n PreART-Clients-not-initiated-on-ART\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n \n \n \n Clients-enrolled-in-Pre-ART-and-seen-in-previous-1-or-2-months\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','2018-03-28 10:39:06',4,'2019-01-24 13:49:58',4,0,NULL,NULL,NULL,'32d35d67-0663-4adf-bfc7-2e9af3ce7faf'),(117,'Clients not initiated on ART SQL Query Version','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients not initiated on ART SQL Query Version\n \n \n 2018-03-29 00:51:58 UTC\n \n 2019-01-31 19:54:24 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 117\n select distinct 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.concept_id = 2223 \nand person_id not in \n (select person_id \n from obs \n where concept_id = 2249 AND \n location_id =:location \n );\n','2018-03-29 00:51:58',4,'2019-01-31 19:54:24',4,0,NULL,NULL,NULL,'ada14623-f50b-4cee-9e9b-7744165da486'),(118,'CI34: Current in Pre-ART clients seen for revisits','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI34: Current in Pre-ART clients seen for revisits\n \n \n 2018-03-29 02:41:52 UTC\n \n 2018-03-29 02: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 118\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-29 04:41:52',4,'2018-03-29 04:43:20',4,0,NULL,NULL,NULL,'c6c76e05-1ee3-43cd-b5e1-a6cf8532f154'),(119,'CI35: Current in Pre-ART clients seen for revisits in previous months','Not seen this month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI35: Current in Pre-ART clients seen for revisits in previous months\n Not seen this month\n \n 2018-03-29 02:45:09 UTC\n \n 2018-03-29 02:49: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 119\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-03-29 04:45:09',4,'2018-03-29 04:49:51',4,0,NULL,NULL,NULL,'6eda74b4-c3d1-4a03-ab99-f274069f3f20'),(120,'Patient Death Query','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.BirthAndDeathCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Patient Death Query\n \n \n 2018-04-17 10:29:46 UTC\n \n \n diedOnOrAfter\n \n java.util.Date\n true\n \n \n diedOnOrBefore\n \n java.util.Date\n true\n \n \n','2018-04-17 12:29:46',4,NULL,NULL,0,NULL,NULL,NULL,'058a4ed9-14ec-46dc-bd83-b99c93da0558'),(123,'Clients ever enrolled on ART','Clients with any date observation of ART Start before the current date','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.DateObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients ever enrolled on ART\n Clients with any date observation of ART Start before the current date\n \n 2018-04-17 12:53:04 UTC\n \n 2019-01-23 08:21:35 UTC\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n value1\n \n java.util.Date\n true\n \n \n 123\n ANY\n \n \n \n \n LESS_EQUAL\n','2018-04-17 14:53:04',4,'2019-01-23 10:21:35',4,0,NULL,NULL,NULL,'761a1a86-745d-4fe7-a656-0eba474bb2d6'),(124,'Clients ever enrolled on ART who died','All clients who died whilst on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients ever enrolled on ART who died\n All clients who died whilst on ART\n \n 2018-04-17 12:57:20 UTC\n \n 2018-04-17 13:00: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 124\n Patient-Death-Query AND Clients-ever-enrolled-on-ART\n \n \n Patient-Death-Query\n \n \n \n \n diedOnOrBefore\n ${endDate}\n \n \n diedOnOrAfter\n ${startDate}\n \n \n \n \n \n Clients-ever-enrolled-on-ART\n \n \n \n \n locationList\n ${location}\n \n \n value1\n ${endDate}\n \n \n \n \n \n','2018-04-17 14:57:20',4,'2018-04-17 15:00:34',4,0,NULL,NULL,NULL,'b51679db-9c8f-4574-b742-8b609a5bd653'),(125,'ART clients Lost','Defined as ART clients who missed their appointment date by 90 or more days','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients Lost\n Defined as ART clients who missed their appointment date by 90 or more days\n \n 2018-04-17 13:32:13 UTC\n \n 2022-04-27 13:52: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 125\n \n select distinct o.person_id \n from obs o \n -- CLIENTS WHO MISSED APPOINTMENTS > 89 DAYS during the month \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l ON o.location_id = l.location_id \n AND o.person_id in ( \n -- begin \n select active_clients.person_id \n from \n ( \n select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up,DATEDIFF(CAST(:endDate AS DATE), B.value_datetime) as num_day, \n case \n -- Added interval of 28,29,30,31 days to 89 days to calculate the number of days in a month(including 89 days that determine LTFU) \n -- determine the max days a client will have if LTFU during period \n when MONTH(CAST(:endDate AS DATE)) = 01 then '120' \n when MONTH(CAST(:endDate AS DATE)) = 02 then '117' \n when MONTH(CAST(:endDate AS DATE)) = 03 then '120' \n when MONTH(CAST(:endDate AS DATE)) = 04 then '119' \n when MONTH(CAST(:endDate AS DATE)) = 05 then '120' \n when MONTH(CAST(:endDate AS DATE)) = 06 then '119' \n when MONTH(CAST(:endDate AS DATE)) = 07 then '120' \n when MONTH(CAST(:endDate AS DATE)) = 08 then '120' \n when MONTH(CAST(:endDate AS DATE)) = 09 then '119' \n when MONTH(CAST(:endDate AS DATE)) = 10 then '120' \n when MONTH(CAST(:endDate AS DATE)) = 11 then '119' \n when MONTH(CAST(:endDate AS DATE)) = 12 then '119' \n else '29' end as days_in_month \n from obs B \n inner join \n \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 \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 having DATEDIFF(CAST(:endDate AS DATE), latest_follow_up) > 89 \n and DATEDIFF(CAST(:endDate AS DATE), latest_follow_up) < days_in_month \n \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 ) \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 \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.obs_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2398 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n \n ) \n \n -- DEAD \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','2018-04-17 13:32:13',4,'2022-04-27 13:52:05',4,0,NULL,NULL,NULL,'e2671095-bdf2-44cf-a857-065e2e2ad518'),(126,'ART clients with Missed Appointments','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients with Missed Appointments\n \n \n 2018-04-17 17:56:59 UTC\n \n 2019-05-02 09: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 126\n select distinct o.person_id \nFROM obs o \nINNER JOIN patient ON o.person_id = patient.patient_id \nand o.concept_id = 3752 \nand o.value_datetime in \n ( \n select latestFU from \n ( \n select distinct os.person_id, max(os.value_datetime) AS latestFU, datediff(CAST(:endDate AS DATE), max(value_datetime)) AS \n Num_Days \n from obs os \n inner join person_name pn on os.person_id = pn.person_id \n inner join patient p on pn.person_id = p.patient_id and pn.voided = 0 \n inner join person ps on ps.person_id = p.patient_id and ps.voided = 0 \n where os.concept_id = 3752 \n and obs_datetime <= :endDate \n group by os.person_id \n having Num_Days > 7 \n and Num_Days < 30 \n ) as lost \n ) \nand o.person_id in \n ( \n select person_id from \n ( \n select distinct os.person_id, max(os.value_datetime) AS latestFU, datediff(CAST(:endDate AS DATE), \n max(value_datetime)) AS Num_Days \n from obs os \n inner join person_name pn on os.person_id = pn.person_id \n inner join patient p on pn.person_id = p.patient_id and pn.voided = 0 \n inner join person ps on ps.person_id = p.patient_id and ps.voided = 0 \n where os.concept_id = 3752 \n and obs_datetime <= :endDate \n group by os.person_id \n having Num_Days > 7 \n and Num_Days < 30 \n ) as lost \n ) \n \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 ) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND o.person_id not in ( \n select person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n;\n','2018-04-17 17:56:59',4,'2019-05-02 09:04:29',4,0,NULL,NULL,NULL,'99784926-bc17-4308-9947-078e59b006ff'),(127,'ART clients who Defaulted','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients who Defaulted\n \n \n 2018-04-17 18:01:09 UTC\n \n 2019-05-02 08: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 127\n select distinct o.person_id \nFROM obs o \nINNER JOIN patient ON o.person_id = patient.patient_id \nand o.concept_id = 3752 \nand o.value_datetime in \n ( \n select latestFU from \n ( \n select distinct os.person_id, max(os.value_datetime) AS latestFU, datediff(CAST(:endDate AS DATE), max(value_datetime)) AS \n Num_Days \n from obs os \n inner join person_name pn on os.person_id = pn.person_id \n inner join patient p on pn.person_id = p.patient_id and pn.voided = 0 \n inner join person ps on ps.person_id = p.patient_id and ps.voided = 0 \n where os.concept_id = 3752 \n and obs_datetime <= :endDate \n group by os.person_id \n having Num_Days > 30 \n and Num_Days < 90 \n ) as defaulter \n ) \nand o.person_id in \n ( \n select person_id from \n ( \n select distinct os.person_id, max(os.value_datetime) AS latestFU, datediff(CAST(:endDate AS DATE), \n max(value_datetime)) AS Num_Days \n from obs os \n inner join person_name pn on os.person_id = pn.person_id \n inner join patient p on pn.person_id = p.patient_id and pn.voided = 0 \n inner join person ps on ps.person_id = p.patient_id and ps.voided = 0 \n where os.concept_id = 3752 \n and obs_datetime <= :endDate \n group by os.person_id \n having Num_Days > 30 \n and Num_Days < 90 \n ) as defaulter \n ) \n \n \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime <= :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND o.person_id not in ( \n select person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n;\n','2018-04-17 18:01:09',4,'2019-05-02 08:58:41',4,0,NULL,NULL,NULL,'32051001-863f-4e02-9165-599c2a3a9137'),(128,'ART clients stopped Query','ART patients who stopped ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients stopped Query\n ART patients who stopped ART\n \n 2018-04-18 07:35:57 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-04-18 09:35:57',4,NULL,NULL,0,NULL,NULL,NULL,'141ce68c-09b5-40ee-9c51-bff2aa09a54d'),(129,'Scheduled appointment','scheduled appointment. this are clients who came on the set date','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Scheduled appointment\n scheduled appointment. this are clients who came on the set date\n \n 2018-04-18 08:30:00 UTC\n \n 2018-04-18 08:31:09 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n 129\n ANY\n \n \n \n \n IN\n \n \n \n','2018-04-18 10:30:00',4,'2018-04-18 10:31:09',4,0,NULL,NULL,NULL,'44383c6e-b552-4703-9f88-faf374ff3b8e'),(130,'All ART drug refill visits','all clients who made a drug pick up visit','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All ART drug refill visits\n all clients who made a drug pick up visit\n \n 2018-04-18 09:45:26 UTC\n \n 2019-01-31 04: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 130\n select distinct person_id \nfrom obs o, encounter e, visit v \nwhere o.encounter_id = e.encounter_id \nand e.visit_id = v.visit_id and \nv.visit_type_id = 10 \nand o.location_id =:location \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate;\n','2018-04-18 09:45:26',4,'2019-01-31 04:58:43',4,0,NULL,NULL,NULL,'da54992a-b327-4dff-a9d7-d9cc53f6697d'),(131,'On time Drug pick-up','Clients who picked their drug refill on the scheduled date','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n On time Drug pick-up\n Clients who picked their drug refill on the scheduled date\n \n 2018-04-18 10:34:10 UTC\n \n 2018-04-18 10:39: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 131\n All-ART-drug-refill-visits AND Scheduled-appointment\n \n \n All-ART-drug-refill-visits\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 Scheduled-appointment\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n','2018-04-18 12:34:10',4,'2018-04-18 12:39:15',4,0,NULL,NULL,NULL,'23622729-be20-496f-ac0f-f6647093eb90'),(132,'ART clients provided nutrition supplements','ART clients provided nutrition suppements','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients provided nutrition supplements\n ART clients provided nutrition suppements\n \n 2018-04-19 10:11:22 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n','2018-04-19 12:11:22',4,NULL,NULL,0,NULL,NULL,NULL,'92e1c320-c133-4f98-9833-ad680b8f5bd5'),(133,'Plumpy Nut','ART clients who received plumpy nut','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Plumpy Nut\n ART clients who received plumpy nut\n \n 2018-04-19 10:22:41 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-04-19 12:22:41',4,NULL,NULL,0,NULL,NULL,NULL,'a1f707c2-4bb8-4d48-8c62-680746e324b2'),(134,'Given F75','Client who were given nutritional support F75','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Given F75\n Client who were given nutritional support F75\n \n 2018-04-19 10:25:36 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-04-19 12:25:36',4,NULL,NULL,0,NULL,NULL,NULL,'20aa6768-f594-4e25-87fb-032f27a018c2'),(135,'Given F100','clients who picked F100','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Given F100\n clients who picked F100\n \n 2018-04-19 10:26:53 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-04-19 12:26:53',4,NULL,NULL,0,NULL,NULL,NULL,'75622551-c46c-4797-a9cf-62ebc4871b86'),(136,'Other nutritional products','Client who were given nutritional support Other nutritional products','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Other nutritional products\n Client who were given nutritional support Other nutritional products\n \n 2018-04-19 10:27:43 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-04-19 12:27:43',4,NULL,NULL,0,NULL,NULL,NULL,'9852762a-1c2e-4bc4-b85f-f90b07245cbd'),(137,'ART clients given cotrimoxazole','ART clients given cotrimoxazole','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.NumericObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients given cotrimoxazole\n ART clients given cotrimoxazole\n \n 2018-04-19 10:43:03 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n GREATER_THAN\n 0.0\n','2018-04-19 12:43:03',4,NULL,NULL,0,NULL,NULL,NULL,'bd653d50-7c8b-4eef-b4df-f43b6895e687'),(138,'HIV positive clients Started IPT','HIV positive clients, in HIV care (preART or ART) Started IPT','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HIV positive clients Started IPT\n HIV positive clients, in HIV care (preART or ART) Started IPT\n \n 2018-04-19 13:45:43 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n IN\n \n \n \n','2018-04-19 15:45:43',4,NULL,NULL,0,NULL,NULL,NULL,'861f8278-7e7b-45b0-b3e4-62fbfbc1658a'),(139,'New pre-ART clients started IPT','New pre-ART clients started IPT','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New pre-ART clients started IPT\n New pre-ART clients started IPT\n \n 2018-04-19 13:57:23 UTC\n \n 2018-04-19 14:09: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 139\n Date-enrolled-in-Pre-ART AND HIV-positive-clients-Started-IPT\n \n \n Date-enrolled-in-Pre-ART\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n HIV-positive-clients-Started-IPT\n \n \n \n \n \n \n','2018-04-19 15:57:23',4,'2018-04-19 16:09:54',4,0,NULL,NULL,NULL,'862c77cd-5bcb-4858-9cd3-d0b60704d05b'),(140,'New ART clients started IPT','New ART clients started IPT','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New ART clients started IPT\n New ART clients started IPT\n \n 2018-04-19 14:10:35 UTC\n \n 2018-04-19 14:16: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 140\n ART-start-date AND HIV-positive-clients-Started-IPT\n \n \n ART-start-date\n \n \n \n \n locationList\n ${location}\n \n \n value2\n ${endDate}\n \n \n value1\n ${startDate}\n \n \n \n \n \n HIV-positive-clients-Started-IPT\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n','2018-04-19 16:10:35',4,'2018-04-19 16:16:14',4,0,NULL,NULL,NULL,'02a211e3-0e79-4f07-b131-84b2c28a7f93'),(141,'No. of persons in original cohort 6 months','No. of persons in original cohort 6 months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n No. of persons in original cohort 6 months\n No. of persons in original cohort 6 months\n \n 2018-04-20 07:40:13 UTC\n \n 2018-10-16 14:41:18 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n 141\n select distinct person_id \nfrom obs o \nwhere location_id =:location \nand o.concept_id = 2249 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH));\n','2018-04-20 09:40:13',4,'2018-10-16 16:41:18',4,0,NULL,NULL,NULL,'d768b001-7c65-49d1-b8db-d3bc04ccbf6c'),(142,'No. of persons in original cohort 12 months','No. of persons in original cohort 12 months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n No. of persons in original cohort 12 months\n No. of persons in original cohort 12 months\n \n 2018-04-20 07:41:37 UTC\n \n 2018-10-16 14:39:12 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n 142\n select distinct person_id \nfrom obs o \nwhere location_id =:location \nand o.concept_id = 2249 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH));\n','2018-04-20 09:41:37',4,'2018-10-16 16:39:12',4,0,NULL,NULL,NULL,'d153ef33-2ae2-43c7-8c1a-ed070d4e0022'),(143,'Number of persons transfer in- 6 months','Number of persons transfer in- 6 months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Number of persons transfer in- 6 months\n Number of persons transfer in- 6 months\n \n 2018-04-20 08:19:32 UTC\n \n 2018-04-20 08: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 143\n select distinct person_id \nfrom obs o \nwhere location_id =:location \nand o.concept_id = 4168 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH))\n','2018-04-20 10:19:32',4,'2018-04-20 10:27:22',4,0,NULL,NULL,NULL,'c9387748-c920-4665-886b-aaae0c5609f9'),(144,'Number of persons transfer in- 12 months','Number of persons transfer in- 12 months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Number of persons transfer in- 12 months\n Number of persons transfer in- 12 months\n \n 2018-04-20 08:22:18 UTC\n \n 2018-04-20 08: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 144\n select distinct person_id \nfrom obs o \nwhere location_id =:location \nand o.concept_id = 4168 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH))\n','2018-04-20 10:22:18',4,'2018-04-20 10:26:32',4,0,NULL,NULL,NULL,'3528e2a5-002d-4a15-8565-e80d7e4a56e1'),(145,'Date transferred out','Date transferred out','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.DateObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Date transferred out\n Date transferred out\n \n 2018-04-20 08:47:48 UTC\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n value1\n \n java.util.Date\n true\n \n \n ANY\n \n \n \n \n LESS_EQUAL\n','2018-04-20 10:47:48',4,NULL,NULL,0,NULL,NULL,NULL,'e085074b-37f3-453c-a51e-7c11b6421d5d'),(146,'Number of persons in cohort transferred out 6 months','Number of persons cohort transferred out 6 months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Number of persons in cohort transferred out 6 months\n Number of persons cohort transferred out 6 months\n \n 2018-04-20 08:53:19 UTC\n \n 2018-04-20 09:16: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 146\n Date-transferred-out AND No.-of-persons-in-original-cohort-6-months\n \n \n Date-transferred-out\n \n \n \n \n locationList\n ${location}\n \n \n value1\n ${endDate}\n \n \n \n \n \n No.-of-persons-in-original-cohort-6-months\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n \n \n \n','2018-04-20 10:53:19',4,'2018-04-20 11:16:16',4,0,NULL,NULL,NULL,'2172c378-b654-491b-8342-a2aec11d99eb'),(148,'Number of persons in cohort transferred out 12 months','Number of persons in cohort transferred out 12 months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Number of persons in cohort transferred out 12 months\n Number of persons in cohort transferred out 12 months\n \n 2018-04-20 09:08:34 UTC\n \n 2018-04-20 09:13: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 148\n Date-transferred-out AND No.-of-persons-in-original-cohort-12-months\n \n \n Date-transferred-out\n \n \n \n \n locationList\n ${location}\n \n \n value1\n ${endDate}\n \n \n \n \n \n No.-of-persons-in-original-cohort-12-months\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n \n \n \n','2018-04-20 11:08:34',4,'2018-04-20 11:13:16',4,0,NULL,NULL,NULL,'e50bdec3-0982-4a13-a94d-c1c860b767b6'),(149,'No. of baseline CD4+ counts 6 months','No. of baseline CD4+ counts 6 months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n No. of baseline CD4+ counts 6 months\n No. of baseline CD4+ counts 6 months\n \n 2018-04-20 09:27:44 UTC\n \n 2019-02-05 08:55: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 149\n select distinct person_id \nfrom obs o \nwhere location_id =:location \nand ((o.concept_id = 1187 and o.value_numeric > 0) OR (o.concept_id = 3661 and o.value_numeric > 0)) \nand MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \nand obs_datetime in \n (select min(os.obs_datetime) from obs os \n where ((o.concept_id = 1187 and o.value_numeric > 0) OR (o.concept_id = 3661 and o.value_numeric > 0)) \n group by os.person_id) \nand person_id in \n (select distinct person_id from obs os \n where ((o.concept_id = 1187 and o.value_numeric > 0) OR (o.concept_id = 3661 and o.value_numeric > 0)));\n','2018-04-20 11:27:44',4,'2019-02-05 10:55:59',4,0,NULL,NULL,NULL,'0a267111-8e29-46c3-8299-cb199c6b74aa'),(150,'No. of baseline CD4+ counts 12 months','No. of baseline CD4+ counts 12 months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n No. of baseline CD4+ counts 12 months\n No. of baseline CD4+ counts 12 months\n \n 2018-04-20 09:40:28 UTC\n \n 2018-10-16 13:38:46 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n 150\n select distinct person_id \nfrom obs o \nwhere location_id =:location \nand ((o.concept_id = 1187 and o.value_numeric > 0) OR (o.concept_id = 3661 and o.value_numeric > 0)) \nand MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \nand obs_datetime in \n (select min(os.obs_datetime) from obs os \n where ((o.concept_id = 1187 and o.value_numeric > 0) OR (o.concept_id = 3661 and o.value_numeric > 0)) \n group by os.person_id) \nand person_id in \n (select distinct person_id from obs os \n where ((o.concept_id = 1187 and o.value_numeric > 0) OR (o.concept_id = 3661 and o.value_numeric > 0)));\n','2018-04-20 11:40:28',4,'2018-10-16 15:38:46',4,0,NULL,NULL,NULL,'3dc23527-d716-4e4b-bb05-7a504e0db44d'),(153,'TestMedian','TestMedian','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.SqlIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TestMedian\n TestMedian\n \n 2018-04-20 11:34:00 UTC\n \n 2018-04-20 11:37:22 UTC\n \n 153\n SELECT \n AVG(sorted_obs.cd4) \nFROM \n (SELECT @rowindex:=@rowindex + 1 AS rowindex, \n o.value_numeric AS cd4 \n FROM obs o \n where location_id = 16 \n and o.concept_id = 1187 \n and MONTH(o.obs_datetime) = MONTH(DATE_ADD(now(), INTERVAL -2 MONTH)) \n ORDER BY o.value_numeric) AS sorted_obs \nWHERE \nsorted_obs.rowindex IN (FLOOR(@rowindex / 2) , CEIL(@rowindex / 2));\n','2018-04-20 13:34:00',4,'2018-04-20 13:37:22',4,0,NULL,NULL,NULL,'a5979205-f1fa-4ebe-ad68-8e3f5d4d311a'),(154,'DM_Weight_Updated','patient weight','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n DM_Weight_Updated\n patient weight\n \n 2018-06-05 07:42:11 UTC\n \n 2018-06-05 07:45:30 UTC\n \n 154\n \n \n 03to3.9kg\n \n \n \n \n value2\n 3.9\n \n \n value1\n 0.0\n \n \n \n \n \n 04to5.9kg\n \n \n \n \n value2\n 5.9\n \n \n value1\n 4.0\n \n \n \n \n \n 06to9.9kg\n \n \n \n \n value2\n 9.9\n \n \n value1\n 6.0\n \n \n \n \n \n 10to13.9kg\n \n \n \n \n value2\n 13.9\n \n \n value1\n 10.0\n \n \n \n \n \n 14to19.9kg\n \n \n \n \n value2\n 19.9\n \n \n value1\n 14.0\n \n \n \n \n \n 20to24.9kg\n \n \n \n \n value2\n 24.9\n \n \n value1\n 20.0\n \n \n \n \n \n 25+kg\n \n \n \n \n value2\n 34.9\n \n \n value1\n 25.0\n \n \n \n \n \n','2018-06-05 09:42:11',4,'2018-06-05 09:45:30',4,0,NULL,NULL,NULL,'3cf562e6-0290-45c0-a999-6133791b0652'),(155,'Clients registered during period','Clients registered during period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients registered during period\n Clients registered during period\n \n 2018-06-05 08:36:35 UTC\n \n 2018-06-08 06:51:40 UTC\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n 155\n ANY\n \n \n \n','2018-06-05 10:36:35',4,'2018-06-08 08:51:40',4,0,NULL,NULL,NULL,'1f5202c9-90ed-4203-ab0c-969c40bd5ec7'),(159,'PIR05: Patient consultation completeness report (Registration vs. Consultation) Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR05: Patient consultation completeness report (Registration vs. Consultation) Data Set\n \n 2018-06-07 10:43:04 UTC\n \n 2018-06-07 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 159\n \n \n \n 900\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 901\n \n \n \n \n \n \n \n \n \n 902\n \n \n \n \n \n \n \n \n \n','2018-06-07 12:43:04',4,'2018-06-07 16:46:17',4,0,NULL,NULL,NULL,'040a8664-4033-4958-bcad-064f51e6889a'),(169,'Clients not registered during period','Clients not registered during period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients not registered during period\n Clients not registered during period\n \n 2018-06-08 06:53:29 UTC\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n ANY\n \n \n \n true\n','2018-06-08 08:53:29',4,NULL,NULL,0,NULL,NULL,NULL,'56bc4ef4-3f60-47bd-b6c4-89f203ee199d'),(170,'Clients not seen for consultation during period','Clients not seen for consultation during period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.EncounterCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients not seen for consultation during period\n Clients not seen for consultation during period\n \n 2018-06-08 06:54:57 UTC\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n ANY\n \n \n \n true\n','2018-06-08 08:54:57',4,NULL,NULL,0,NULL,NULL,NULL,'1791b273-ab2c-4d1b-9029-77203be5ea4d'),(171,'Clients not registered but seen for consultation during the period','Clients not registered but seen for consultation during the period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients not registered but seen for consultation during the period\n Clients not registered but seen for consultation during the period\n \n 2018-06-08 06:57:10 UTC\n \n 2018-06-08 07:05: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 171\n Clients-seen-for-consultation AND Clients-not-registered-during-period\n \n \n Clients-seen-for-consultation\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n Clients-not-registered-during-period\n \n \n \n \n \n \n','2018-06-08 08:57:10',4,'2018-06-08 09:05:55',4,0,NULL,NULL,NULL,'331400b1-dd20-4e48-b06c-28356df8e88b'),(172,'Clients registered and not seen for consultation','Clients registered and not seen for consultation','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients registered and not seen for consultation\n Clients registered and not seen for consultation\n \n 2018-06-08 07:06:23 UTC\n \n 2018-06-08 07:41: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 172\n Clients-registered-during-period AND Clients-not-seen-for-consultation-during-period\n \n \n Clients-registered-during-period\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n Clients-not-seen-for-consultation-during-period\n \n \n \n \n \n \n','2018-06-08 09:06:23',4,'2018-06-08 09:41:52',4,0,NULL,NULL,NULL,'6ed321bb-a8b7-4c95-aed0-9f126b9225c0'),(173,'Clients registered and seen for consultation during period','Clients registered and seen for consultation during period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients registered and seen for consultation during period\n Clients registered and seen for consultation during period\n \n 2018-06-08 07:11:35 UTC\n \n 2018-06-08 07:13: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 173\n Clients-seen-for-consultation AND Clients-registered-during-period\n \n \n Clients-seen-for-consultation\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n Clients-registered-during-period\n \n \n \n \n \n \n','2018-06-08 09:11:35',4,'2018-06-08 09:13:37',4,0,NULL,NULL,NULL,'c2ff0485-8637-4415-893d-70b6b18c1c71'),(174,'Clients not registered but seen for consultation during the period','Clients not registered but seen for consultation during the period','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients not registered but seen for consultation during the period\n Clients not registered but seen for consultation during the period\n \n 2018-06-08 07:14:53 UTC\n \n 2018-06-08 07:15: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 174\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-06-08 09:14:53',4,'2018-06-08 09:15:36',4,0,NULL,NULL,NULL,'7874aba7-94c7-43be-9601-0aeee2fafe41'),(175,'Clients not seen for consultation during period','Clients not seen for consultation during period','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients not seen for consultation during period\n Clients not seen for consultation during period\n \n 2018-06-08 07:16:43 UTC\n \n 2018-06-08 07:17: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 175\n COUNT\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n','2018-06-08 09:16:43',4,'2018-06-08 09:17:27',4,0,NULL,NULL,NULL,'5697c599-0bc4-45e2-b2d7-23b6643742db'),(176,'Clients registered and not seen for consultation','Clients registered and not seen for consultation','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients registered and not seen for consultation\n Clients registered and not seen for consultation\n \n 2018-06-08 07:18:15 UTC\n \n 2018-06-08 07:18: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 176\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-06-08 09:18:15',4,'2018-06-08 09:18:48',4,0,NULL,NULL,NULL,'786a69e3-f9a4-4aad-903c-b511c7bca134'),(177,'Clients with visits and documented vitals encounter with documented consultation during period','Clients with visits and documented vitals encounter with documented consultation during period','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with visits and documented vitals encounter with documented consultation during period\n Clients with visits and documented vitals encounter with documented consultation during period\n \n 2018-06-08 07:19:27 UTC\n \n 2018-06-17 05: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 177\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-06-08 07:19:27',4,'2018-06-17 05:17:09',4,0,NULL,NULL,NULL,'2b76b4a6-12ab-43f1-b4fd-f0baf1f31e35'),(178,'Clients with visits and documented vitals encounter at registration during period','Clients registered during period','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with visits and documented vitals encounter at registration during period\n Clients registered during period\n \n 2018-06-08 07:20:29 UTC\n \n 2018-06-17 05:17: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 178\n COUNT\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n','2018-06-08 07:20:29',4,'2018-06-17 05:17:58',4,0,NULL,NULL,NULL,'b6c39f5c-2e9b-4250-9216-5a6eb1cabfca'),(179,'Clients seen for consultation during period','Clients seen for consultation during period','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen for consultation during period\n Clients seen for consultation during period\n \n 2018-06-08 07:21:56 UTC\n \n 2018-06-08 07:24: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 179\n COUNT\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n','2018-06-08 09:21:56',4,'2018-06-08 09:24:22',4,0,NULL,NULL,NULL,'3323b353-6f81-44b5-80d8-41b31c1071f0'),(180,'Percentage of clients with visits started but not seen for consultation during period','Percentage of clients with visits started but not seen for consultation during period','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Percentage of clients with visits started but not seen for consultation during period\n Percentage of clients with visits started but not seen for consultation during period\n \n 2018-06-08 07:24:56 UTC\n \n 2018-10-29 15:30: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 180\n FRACTION\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n \n \n locationList\n ${location}\n \n \n stoppedOnOrBefore\n ${endDate}\n \n \n startedOnOrAfter\n ${startDate}\n \n \n \n','2018-06-08 09:24:56',4,'2018-10-29 17:30:13',4,0,NULL,NULL,NULL,'e4155685-6661-42d0-9c74-be6a136eef5b'),(181,'Percentage of clients with visits started and also seen for consultation during period','Percentage of clients with visits started and also seen for consultation during period','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Percentage of clients with visits started and also seen for consultation during period\n Percentage of clients with visits started and also seen for consultation during period\n \n 2018-06-08 07:26:26 UTC\n \n 2018-10-29 15:28: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 181\n FRACTION\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n \n \n locationList\n ${location}\n \n \n stoppedOnOrBefore\n ${endDate}\n \n \n startedOnOrAfter\n ${startDate}\n \n \n \n','2018-06-08 09:26:26',4,'2018-10-29 17:28:47',4,0,NULL,NULL,NULL,'e7f1eed7-f423-42e0-a37e-74e41ddfe4da'),(182,'PIR99: Registration vs Consultation (Completeness)','Registration vs Consultation (Completeness)','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR99: Registration vs Consultation (Completeness)\n Registration vs Consultation (Completeness)\n \n 2018-06-08 07:28:55 UTC\n \n 2018-06-08 07:28: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 182\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','2018-06-08 09:28:55',4,'2018-06-08 09:28:56',4,0,NULL,NULL,NULL,'685dbc9b-752a-4b5b-a948-8bd8830f80fb'),(183,'PIR99: Registration vs Consultation (Completeness) Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR99: Registration vs Consultation (Completeness) Data Set\n \n 2018-06-08 07:28:56 UTC\n \n 2018-10-15 13:22: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 183\n \n \n \n 900\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 901\n \n \n \n \n \n \n \n \n \n 903\n \n \n \n \n \n \n \n \n \n 904\n \n \n \n \n \n \n \n \n \n 905\n \n \n \n \n \n \n \n \n \n 906\n \n \n \n \n \n \n \n \n \n 907\n \n \n \n \n \n \n \n \n \n 908\n \n \n \n \n \n \n \n \n \n 909\n \n \n \n \n \n \n \n \n \n 910\n \n \n \n \n \n \n \n \n \n','2018-06-08 09:28:56',4,'2018-10-15 15:22:12',4,0,NULL,NULL,NULL,'6a4ca4b9-1fce-4ab1-b1dd-7d3d68c7e40a'),(184,'CI_Clients_seen','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI_Clients_seen\n \n \n 2018-06-08 10:21:40 UTC\n \n 2019-01-31 18:09: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 184\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-06-08 10:21:40',4,'2019-01-31 18:09:56',4,0,NULL,NULL,NULL,'ec42c51f-70c7-437f-8d1b-00d531626486'),(185,'Clients with visits started during period','Clients with visits started during period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.VisitCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with visits started during period\n Clients with visits started during period\n \n 2018-06-17 05:01:34 UTC\n \n 2018-10-29 15:24:40 UTC\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n startedOnOrAfter\n \n java.util.Date\n true\n \n \n stoppedOnOrBefore\n \n java.util.Date\n true\n \n \n 185\n false\n','2018-06-17 07:01:34',4,'2018-10-29 17:24:40',4,0,NULL,NULL,NULL,'2e034999-51ce-4694-8cfa-3892c11c9d83'),(186,'Clients with an active visit during period','Clients with an active visit during period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.VisitCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with an active visit during period\n Clients with an active visit during period\n \n 2018-06-17 05:03:41 UTC\n \n 2018-06-17 05:05:02 UTC\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n activeOnOrAfter\n \n java.util.Date\n true\n \n \n activeOnOrBefore\n \n java.util.Date\n true\n \n \n 186\n true\n false\n','2018-06-17 05:03:41',4,'2018-06-17 05:05:02',4,0,NULL,NULL,NULL,'18a150f9-baa1-47a1-a81f-8cdbf0e11bb7'),(187,'Clients with visits started during period','Clients with active visits which were started during period','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with visits started during period\n Clients with active visits which were started during period\n \n 2018-06-17 05:06:57 UTC\n \n 2018-10-29 15:26: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 187\n COUNT\n \n \n \n \n locationList\n ${location}\n \n \n stoppedOnOrBefore\n ${endDate}\n \n \n startedOnOrAfter\n ${startDate}\n \n \n \n','2018-06-17 07:06:57',4,'2018-10-29 17:26:02',4,0,NULL,NULL,NULL,'94e360fc-bc15-4848-8af4-c49a1fc30cc9'),(188,'Clients with an active visit during period','Clients with an active visit during period','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with an active visit during period\n Clients with an active visit during period\n \n 2018-06-17 05:09:21 UTC\n \n 2018-06-17 05:10: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 188\n COUNT\n \n \n \n \n locationList\n ${location}\n \n \n activeOnOrAfter\n ${startDate}\n \n \n activeOnOrBefore\n ${endDate}\n \n \n \n','2018-06-17 05:09:21',4,'2018-06-17 05:10:06',4,0,NULL,NULL,NULL,'0093fd77-6601-466d-abf7-bc38c91291ff'),(189,'All patients','All patients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.AllPatientsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All patients\n All patients\n \n 2018-06-19 11:07:07 UTC\n \n','2018-06-19 11:07:07',4,NULL,NULL,0,NULL,NULL,NULL,'2ba82672-5807-417c-bd4f-85216bee2b75'),(190,'Ratio of patient registered to those who are current of ART','Ratio of patient registered to those who are current of ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ratio of patient registered to those who are current of ART\n Ratio of patient registered to those who are current of ART\n \n 2018-06-19 11:08:40 UTC\n \n 2018-06-19 11:09:15 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 190\n FRACTION\n \n \n \n \n','2018-06-19 11:08:40',4,'2018-06-19 11:09:15',4,0,NULL,NULL,NULL,'5d1d8893-ea50-4e58-900f-21bbd217d9a5'),(192,'New on ART_test','sql script here','org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.SqlDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New on ART_test\n sql script here\n \n 2018-06-29 12:04:50 UTC\n \n 2018-06-29 12:14:22 UTC\n \n 192\n select * from visit where date_started >= '20-jun-2018'\n','2018-06-29 17:34:50',4,'2018-06-29 17:44:22',4,0,NULL,NULL,NULL,'d1b7fbd9-eabb-4a41-b40a-a0000bc9bb7d'),(194,'PIR06: Presumptive TB Cases Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR06: Presumptive TB Cases Data Set\n \n 2018-07-11 13:00:39 UTC\n \n 2018-07-11 15:17: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 194\n \n \n Gender\n \n \n \n \n \n \n DM_Age\n \n \n \n \n \n \n \n \n ScrinAdulF\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 Gender\n Females\n \n \n DM_Age\n Adults\n \n \n \n \n \n ScrinAdulM\n \n \n \n \n Gender\n Males\n \n \n DM_Age\n Adults\n \n \n \n \n \n ScrinKidsF\n \n \n \n \n Gender\n Females\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n ScrinKidsM\n \n \n \n \n Gender\n Males\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n TBCaseAdF\n \n \n \n \n \n \n \n \n \n TBCaseAdM\n \n \n \n \n \n \n TBCaseChF\n \n \n \n \n \n \n TBCaseChM\n \n \n \n \n \n \n TBTreatAdF\n \n \n \n \n \n \n \n \n \n TBTreatAdM\n \n \n \n \n \n \n TBTreatChF\n \n \n \n \n \n \n TBTreatChM\n \n \n \n \n \n \n','2018-07-11 18:30:39',4,'2018-07-11 20:47:59',4,0,NULL,NULL,NULL,'0f8411d8-3f05-4bdf-aec2-8e98424dc083'),(195,'Male','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.GenderCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Male\n \n \n 2018-07-11 13:13:49 UTC\n \n true\n false\n false\n','2018-07-11 18:43:49',4,NULL,NULL,0,NULL,NULL,NULL,'8d691fae-5ceb-43dc-b4d6-5bac71678c96'),(196,'Presumptive TB Cases','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.InProgramCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Presumptive TB Cases\n \n \n 2018-07-11 13:26:30 UTC\n \n \n onDate\n \n java.util.Date\n true\n \n \n \n \n \n','2018-07-11 18:56:30',4,NULL,NULL,0,NULL,NULL,NULL,'b8632f66-eaff-4483-ace7-77ad437ae84f'),(198,'PIR06: Presumptive TB Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR06: Presumptive TB Data Set\n \n 2018-07-11 13: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 \n \n','2018-07-11 19:24:59',4,NULL,NULL,0,NULL,NULL,NULL,'b7cbdb76-1601-4381-a659-c08f500a0692'),(199,'Diagnosed with TB and started on treatment','No of people diagnosed with TB and started on TB treatment this month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Diagnosed with TB and started on treatment\n No of people diagnosed with TB and started on TB treatment this month\n \n 2018-07-11 14:46:45 UTC\n \n 2020-08-04 17:07: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 199\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-07-11 14:46:45',4,'2020-08-04 17:07:57',4,0,NULL,NULL,NULL,'026262eb-a4f9-4efa-95c1-08c7e3379bcb'),(200,'Lost Clients Indicator','counts clients we have not seen in over 90 days','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Lost Clients Indicator\n counts clients we have not seen in over 90 days\n \n 2018-08-01 10:27:04 UTC\n \n 2018-08-01 14:02: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 200\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-08-01 15:57:04',4,'2018-08-01 19:32:54',4,0,NULL,NULL,NULL,'7a98264d-45da-4d7f-a6f8-2d26af7c761f'),(202,'Lost CLients 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 Lost CLients Report Data Set\n \n 2018-08-01 12:22:39 UTC\n \n 2018-08-01 14:38: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 202\n \n \n DM_Sex\n \n \n \n \n \n \n \n \n LostClient\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','2018-08-01 17:52:39',4,'2018-08-01 20:08:09',4,0,NULL,NULL,NULL,'f3477198-4d0c-417f-8bae-8a537e014a99'),(203,'Missed Appointments Indicator','These are clients whose appointments are over 7 days due','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Missed Appointments Indicator\n These are clients whose appointments are over 7 days due\n \n 2018-08-01 14:09:12 UTC\n \n 2018-08-01 14:12: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 203\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-08-01 19:39:12',4,'2018-08-01 19:42:27',4,0,NULL,NULL,NULL,'e03fafd4-1495-4a09-b01f-f899be47cb38'),(205,'Missed Appointments 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 Missed Appointments Report Data Set\n \n 2018-08-01 14:41:28 UTC\n \n 2018-08-01 14:52: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 205\n \n \n DM_Sex\n \n \n \n \n \n \n \n \n MissedAP-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 MissedAP-M\n \n \n \n \n DM_Sex\n Males\n \n \n \n \n \n','2018-08-01 20:11:28',4,'2018-08-01 20:22:07',4,0,NULL,NULL,NULL,'22300a2c-9096-4518-bb47-cae4c283bd72'),(206,'Defaulters Indicator','clients who havent come for appointments for over 7 days but less than 90','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Defaulters Indicator\n clients who havent come for appointments for over 7 days but less than 90\n \n 2018-08-01 15:10:40 UTC\n \n 2018-08-01 15:24: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 206\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-08-01 20:40:40',4,'2018-08-01 20:54:58',4,0,NULL,NULL,NULL,'0ec8e212-181e-41a3-9726-ff31fcf99c21'),(208,'Defaulted 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 Defaulted Report Data Set\n \n 2018-08-01 15:28:51 UTC\n \n 2018-08-01 15:30: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 208\n \n \n \n Defaulters\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','2018-08-01 20:58:51',4,'2018-08-01 21:00:11',4,0,NULL,NULL,NULL,'c41a9e0d-ac74-443f-98cf-52b341ecc1b2'),(209,'Clients who did not pick up ARV lost','Persons who did not pick upp their ARV regimen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients who did not pick up ARV lost\n Persons who did not pick upp their ARV regimen\n \n 2018-08-02 13:47:29 UTC\n \n 2018-08-03 07:09: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 209\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-08-02 19:17:29',4,'2018-08-03 12:39:42',4,0,NULL,NULL,NULL,'ddcbd8c5-7e15-4006-be8b-0428db54bc51'),(211,'PIR_07_Persons_who_did_not_pick_up_their_ARV_regimen Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR_07_Persons_who_did_not_pick_up_their_ARV_regimen Data Set\n \n 2018-08-02 13:57:46 UTC\n \n 2018-08-02 14:05: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 211\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n \n \n \n \n LostAdultF\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 Adults\n \n \n \n \n \n','2018-08-02 19:27:46',4,'2018-08-02 19:35:08',4,0,NULL,NULL,NULL,'6dbb2065-f8d0-4740-ba44-0e8f5cb5ced0'),(212,'Clients who died','Didnt pick up ARV due to death','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients who died\n Didnt pick up ARV due to death\n \n 2018-08-02 14:22:00 UTC\n \n 2019-03-29 06:58: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 212\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-08-02 14:22:00',4,'2019-03-29 06:58:08',4,0,NULL,NULL,NULL,'54fccccb-8c30-4235-a6a2-b40a3a6cc2ab'),(213,'Reason not yet known','didnt pick up ARV for unknown reasons','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Reason not yet known\n didnt pick up ARV for unknown reasons\n \n 2018-08-02 14:34:48 UTC\n \n 2018-08-02 14:56: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 213\n COUNT\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n','2018-08-02 20:04:48',4,'2018-08-02 20:26:02',4,0,NULL,NULL,NULL,'a15498e0-c11d-4691-aec6-be8cda80543d'),(214,'Clients not seen for unknown reasons','clients who didnt pick up their ARVs for unknown reasons','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients not seen for unknown reasons\n clients who didnt pick up their ARVs for unknown reasons\n \n 2018-08-02 15:04:22 UTC\n \n 2019-01-23 13:55: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 214\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-08-02 17:04:22',4,'2019-01-23 15:55:44',4,0,NULL,NULL,NULL,'e30a1ade-3819-40c5-b6f6-bc031d22e3ce'),(216,'PIR_NO_PICKUP_TEST Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR_NO_PICKUP_TEST Data Set\n \n 2018-08-02 15:17:09 UTC\n \n 2018-08-02 15:20: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 216\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n \n \n \n \n LostAdultF\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 Adults\n \n \n \n \n \n','2018-08-02 20:47:09',4,'2018-08-02 20:50:06',4,0,NULL,NULL,NULL,'16735ee0-0160-43f8-8eb4-beee79866db9'),(217,'Clients who picked up their ARVs','Number of persons who picked up their ARV regimens on time','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients who picked up their ARVs\n Number of persons who picked up their ARV regimens on time\n \n 2018-08-03 07:01:40 UTC\n \n 2019-02-03 11:21: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 217\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-08-03 07:01:40',4,'2019-02-03 11:21:37',4,0,NULL,NULL,NULL,'6fa66b18-d626-4ffa-bc4d-99aacb661f68'),(219,'TEst Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TEst Data Set\n \n 2018-08-03 07:05:32 UTC\n \n 2018-08-03 07:06: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 219\n \n \n \n ddfgh\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 gthhgh\n \n \n \n \n \n \n \n \n \n','2018-08-03 12:35:32',4,'2018-08-03 12:36:53',4,0,NULL,NULL,NULL,'9c60044d-a35f-45fb-81d7-2ec6fff3c769'),(220,'PIR07_Clients_who_did_not_pick_up_ARV','Persons who did not pick up their ARV regimens for different reasons, lost,died,unknown reason and those who stopped ART','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR07_Clients_who_did_not_pick_up_ARV\n Persons who did not pick up their ARV regimens for different reasons, lost,died,unknown reason and those who stopped ART\n \n 2018-08-03 07:10:51 UTC\n \n 2018-08-03 10:43: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 220\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','2018-08-03 12:40:51',4,'2018-08-03 16:13:16',4,0,NULL,NULL,NULL,'a4d5077a-b21c-473b-9636-8dc0237a9bb7'),(221,'Clients_who_did Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients_who_did Data Set\n \n 2018-08-03 07:10:52 UTC\n \n 2019-02-03 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 221\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n \n \n \n \n DiedAdultF\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 Adults\n \n \n \n \n \n DiedAdultM\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Adults\n \n \n \n \n \n DiedChild\n \n \n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n LostAdultF\n \n \n \n \n \n \n \n \n \n LostAdultM\n \n \n \n \n \n \n LostChild\n \n \n \n \n \n \n StoppedAdF\n \n \n \n \n \n \n \n \n \n StoppedAdM\n \n \n \n \n \n \n StoppedChi\n \n \n \n \n \n \n UnknownADF\n \n \n \n \n \n \n \n \n \n UnknownADM\n \n \n \n \n \n \n UnknownChi\n \n \n \n \n \n \n','2018-08-03 07:10:52',4,'2019-02-03 10:45:21',4,0,NULL,NULL,NULL,'41f52fdf-9b2f-4f40-9420-19f8470f76fa'),(222,'Stopped ART','Clients who did not pick up ARVs because they stopped ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Stopped ART\n Clients who did not pick up ARVs because they stopped ART\n \n 2018-08-03 08:50:56 UTC\n \n 2022-04-28 08: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 222\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-08-03 08:50:56',4,'2022-04-28 08:56:27',4,0,NULL,NULL,NULL,'7303b17a-e4ab-4b5e-b3ce-7880cf36bade'),(223,'On_time_pick_up','Number of persons who picked up their ARV regimens on time','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n On_time_pick_up\n Number of persons who picked up their ARV regimens on time\n \n 2018-08-03 09:11:49 UTC\n \n 2018-08-03 09:11: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 223\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','2018-08-03 14:41:49',4,'2018-08-03 14:41:50',4,0,NULL,NULL,NULL,'fcb6a10d-d364-4aa3-a8fc-f4fbb961cbe4'),(224,'On_time_pick_up Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n On_time_pick_up Data Set\n \n 2018-08-03 09:11:50 UTC\n \n 2018-08-03 09:12: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 224\n \n \n \n TimePickUp\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','2018-08-03 14:41:50',4,'2018-08-03 14:42:57',4,0,NULL,NULL,NULL,'75ff5ab7-0178-40ad-9960-d641a8895a7c'),(225,'NutritionalSupp1','Number of clients who received nutritional supplements RUFT- Plumpy nut','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n NutritionalSupp1\n Number of clients who received nutritional supplements RUFT- Plumpy nut\n \n 2018-08-03 09:21:57 UTC\n \n 2018-08-03 09:23: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 225\n COUNT\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n','2018-08-03 14:51:57',4,'2018-08-03 14:53:18',4,0,NULL,NULL,NULL,'e871b95a-9ea4-4dfe-8b2a-dd2c569bc2f7'),(226,'NutritionalSupp2','No of clients who received nutritional supplement F100','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n NutritionalSupp2\n No of clients who received nutritional supplement F100\n \n 2018-08-03 09:24:35 UTC\n \n 2018-08-03 09:25: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 226\n COUNT\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n','2018-08-03 14:54:35',4,'2018-08-03 14:55:39',4,0,NULL,NULL,NULL,'c63d9c45-d226-4110-8f54-e8a50ddcec95'),(227,'NutriotionalSupp3','NO of clients who received nutritional supplement F75','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n NutriotionalSupp3\n NO of clients who received nutritional supplement F75\n \n 2018-08-03 09:26:57 UTC\n \n 2018-08-03 09:27: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 227\n COUNT\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n','2018-08-03 14:56:57',4,'2018-08-03 14:57:56',4,0,NULL,NULL,NULL,'0a8b4609-1638-40a5-9b34-03a8de87a6a6'),(228,'NutritionalSupp4','No of clients who received nutritional supplement Other1','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n NutritionalSupp4\n No of clients who received nutritional supplement Other1\n \n 2018-08-03 09:29:48 UTC\n \n 2018-08-03 09:32: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 228\n COUNT\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n','2018-08-03 14:59:48',4,'2018-08-03 15:02:07',4,0,NULL,NULL,NULL,'83de7902-07a8-4ad8-a28d-efda8a8c302b'),(229,'Clients who received Cotrimox','Clients who received Cotrimox','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients who received Cotrimox\n Clients who received Cotrimox\n \n 2018-08-03 09:34:41 UTC\n \n 2019-02-03 11:53: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 229\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-08-03 09:34:41',4,'2019-02-03 11:53:59',4,0,NULL,NULL,NULL,'fe5bdf32-e7d2-4239-943e-38eb65e4b4ac'),(230,'Newly Enrolled in HIV care Started IPT','Newly Enrolled in HIV/ care Started IPT','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Newly Enrolled in HIV care Started IPT\n Newly Enrolled in HIV/ care Started IPT\n \n 2018-08-03 09:36:54 UTC\n \n 2019-02-03 20:20: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 230\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-08-03 09:36:54',4,'2019-02-03 20:20:25',4,0,NULL,NULL,NULL,'0dfe1170-9501-446f-8c7d-515881db67e4'),(231,'newly started on ART and IPT','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n newly started on ART and IPT\n \n \n 2018-08-03 10:23:17 UTC\n \n 2019-02-03 20:21: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 231\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-08-03 10:23:17',4,'2019-02-03 20:21:44',4,0,NULL,NULL,NULL,'b0be49b4-1ac5-4165-a934-05823c8faa5e'),(233,'PIR08: Nutritional_Supplement Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR08: Nutritional_Supplement Data Set\n \n 2018-08-03 10:45:54 UTC\n \n 2018-08-06 07:13: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 233\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n \n \n \n \n Nutri2AduF\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 Adults\n \n \n \n \n \n Nutri2AduM\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Adults\n \n \n \n \n \n Nutri2ChiF\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n Nutri2ChiM\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n Nutri3AduF\n \n \n \n \n \n \n \n \n \n Nutri3AduM\n \n \n \n \n \n \n Nutri3ChiF\n \n \n \n \n \n \n Nutri3ChiM\n \n \n \n \n \n \n Nutri4AduF\n \n \n \n \n \n \n \n \n \n Nutri4AduM\n \n \n \n \n \n \n Nutri4ChiF\n \n \n \n \n \n \n Nutri4ChiM\n \n \n \n \n \n \n NutriAduF\n \n \n \n \n \n \n \n \n \n NutriAduM\n \n \n \n \n \n \n NutriChiF\n \n \n \n \n \n \n NutriChiM\n \n \n \n \n \n \n','2018-08-03 16:15:54',4,'2018-08-06 12:43:45',4,0,NULL,NULL,NULL,'6293f829-6d59-4aff-a121-5af73e522c28'),(235,'PIR10: Cotrimox Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR10: Cotrimox Data Set\n \n 2018-08-06 07:44:19 UTC\n \n 2019-03-11 17:35: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 235\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age_DATE\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n DM_Age\n \n \n \n \n \n \n \n \n Cotr6to14F\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_DATE\n 06yrs-14yrs\n \n \n \n \n \n Cotr6to14M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n 06yrs-14yrs\n \n \n \n \n \n Cotri5mtsF\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n <6Months\n \n \n \n \n \n Cotri5mtsM\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n <6Months\n \n \n \n \n \n Cotri6to5F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age_DATE\n 06Mnths-5yrs\n \n \n \n \n \n Cotri6to5M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age_DATE\n 06Mnths-5yrs\n \n \n \n \n \n CotriAduF\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Adults\n \n \n \n \n \n CotriAduM\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Adults\n \n \n \n \n \n','2018-08-06 07:44:19',4,'2019-03-11 17:35:13',4,0,NULL,NULL,NULL,'ce6e1b61-d77d-430c-85ea-5f2c8499cb69'),(237,'Month_to_month_age_cohort','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.AgeCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Month_to_month_age_cohort\n \n \n 2018-08-06 09:02:48 UTC\n \n 2018-08-06 09:15:44 UTC\n \n \n minAge\n \n java.lang.Integer\n true\n \n \n maxAge\n \n java.lang.Integer\n true\n \n \n 237\n MONTHS\n MONTHS\n false\n','2018-08-06 14:32:48',4,'2018-08-06 14:45:44',4,0,NULL,NULL,NULL,'b0fc9529-1c40-4ad0-b458-ef1d530c11ec'),(238,'Month_to_year_age_cohort','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.AgeCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Month_to_year_age_cohort\n \n \n 2018-08-06 09:05:50 UTC\n \n 2018-08-06 09:19:22 UTC\n \n \n minAge\n \n java.lang.Integer\n true\n \n \n maxAge\n \n java.lang.Integer\n true\n \n \n 238\n MONTHS\n YEARS\n false\n','2018-08-06 14:35:50',4,'2018-08-06 14:49:22',4,0,NULL,NULL,NULL,'88e4af2a-3f98-405c-b041-af814a86668c'),(240,'Isoniazid Preventive Therapy Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Isoniazid Preventive Therapy Data Set\n \n 2018-08-06 10:08:29 UTC\n \n 2019-03-11 17:42: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 240\n \n \n DM_Age_DATE\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n DM_Age\n \n \n \n \n \n \n \n \n IPTart0to4\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_Age_DATE\n 0Mnths-4yrs\n \n \n \n \n \n IPTart15\n \n \n \n \n DM_Age_DATE\n 15+yrs\n \n \n \n \n \n IPTat5to14\n \n \n \n \n DM_Age_DATE\n 05yrsto14yrs\n \n \n \n \n \n IPTpr5to14\n \n \n \n \n \n \n \n \n \n IPTpre0to4\n \n \n \n \n \n \n IPTpre15\n \n \n \n \n \n \n','2018-08-06 10:08:29',4,'2019-03-11 17:42:02',4,0,NULL,NULL,NULL,'f3cc2da8-ca50-481d-9010-d0614a43606e'),(242,'Change_in_CD4_Count Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Change_in_CD4_Count Data Set\n \n 2018-10-16 12:45:37 UTC\n \n 2019-02-05 09:54: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 242\n \n \n \n Dead12mts\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 Dead6mts\n \n \n \n \n \n \n \n \n \n TransOut12\n \n \n \n \n \n \n \n \n \n TransOut6m\n \n \n \n \n \n \n \n \n \n alt1st12m\n \n \n \n \n \n \n \n \n \n alt1st6m\n \n \n \n \n \n \n \n \n \n basecd412m\n \n \n \n \n \n \n \n \n \n basecd46m\n \n \n \n \n \n \n \n \n \n follow12mt\n \n \n \n \n \n \n \n \n \n follow6mt\n \n \n \n \n \n \n \n \n \n lost12mts\n \n \n \n \n \n \n \n \n \n lost6mts\n \n \n \n \n \n \n \n \n \n origin12mn\n \n \n \n \n \n \n \n \n \n origin6mnt\n \n \n \n \n \n \n \n \n \n stil1st12m\n \n \n \n \n \n \n \n \n \n stil1st6m\n \n \n \n \n \n \n \n \n \n stopped12m\n \n \n \n \n \n \n \n \n \n stopped6mt\n \n \n \n \n \n \n \n \n \n swich2nd12\n \n \n \n \n \n \n \n \n \n switch2nd6\n \n \n \n \n \n \n \n \n \n transIn12m\n \n \n \n \n \n \n \n \n \n transIn6mn\n \n \n \n \n \n \n \n \n \n viral12mts\n \n \n \n \n \n \n \n \n \n viral6mts\n \n \n \n \n \n \n \n \n \n','2018-10-16 14:45:37',4,'2019-02-05 11:54:13',4,0,NULL,NULL,NULL,'e396adf4-cca6-4add-9638-46750e10468b'),(243,'Number of persons in original cohort 6 mnths','Number of persons in original cohort 6 mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Number of persons in original cohort 6 mnths\n Number of persons in original cohort 6 mnths\n \n 2018-10-16 12:54:53 UTC\n \n 2018-10-16 13:15: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 243\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n \n','2018-10-16 14:54:53',4,'2018-10-16 15:15:13',4,0,NULL,NULL,NULL,'9bfc4aae-1960-41e9-b763-c6ed0af8416e'),(244,'Number of persons in original cohort 12 mnths','Number of persons in original cohort 12 mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Number of persons in original cohort 12 mnths\n Number of persons in original cohort 12 mnths\n \n 2018-10-16 12:57:51 UTC\n \n 2018-10-16 13: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 244\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n \n','2018-10-16 14:57:51',4,'2018-10-16 15:12:54',4,0,NULL,NULL,NULL,'4db88cd3-7834-419e-9078-cf8c676c317e'),(245,'Persons transfer in 6 months','number of persons transfer in 6 months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Persons transfer in 6 months\n number of persons transfer in 6 months\n \n 2018-10-16 13:04:30 UTC\n \n 2018-10-16 13:06:52 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 245\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-10-16 15:04:30',4,'2018-10-16 15:06:52',4,0,NULL,NULL,NULL,'087ec921-1bc9-4801-8a08-b42c30c0e182'),(246,'Persons transfer in 12 months','Number of persons transferred in 12 months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Persons transfer in 12 months\n Number of persons transferred in 12 months\n \n 2018-10-16 13:08:13 UTC\n \n 2018-10-16 13:09: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 246\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-10-16 15:08:13',4,'2018-10-16 15:09:51',4,0,NULL,NULL,NULL,'4a013856-0a85-49fb-8b38-b56ad12f91e8'),(247,'Persons transfer out 6 months','number of persons transferred out 6 months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Persons transfer out 6 months\n number of persons transferred out 6 months\n \n 2018-10-16 13:27:14 UTC\n \n 2018-10-16 13:34: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 247\n select distinct person_id \nfrom obs o \nwhere location_id =:location \nand o.concept_id = 2398 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH))\n','2018-10-16 15:27:14',4,'2018-10-16 15:34:20',4,0,NULL,NULL,NULL,'a5e955fe-3d68-426e-be12-bfdd8ae80f0e'),(248,'Persons transfer out 12 months','Number of persons transferred out 12 months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Persons transfer out 12 months\n Number of persons transferred out 12 months\n \n 2018-10-16 13:36:21 UTC\n \n 2018-10-16 13:37: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 248\n select distinct person_id \nfrom obs o \nwhere location_id =:location \nand o.concept_id = 2398 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH))\n','2018-10-16 15:36:21',4,'2018-10-16 15:37:17',4,0,NULL,NULL,NULL,'d1cb0ee5-2dba-4ee8-8661-fdf9e2b67d47'),(249,'Persons transfer out 12 months','number of persons transferred out 12 months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Persons transfer out 12 months\n number of persons transferred out 12 months\n \n 2018-10-16 14:15:41 UTC\n \n 2018-10-16 14:17: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 249\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-10-16 16:15:41',4,'2018-10-16 16:17:54',4,0,NULL,NULL,NULL,'0695ac41-71c8-44b9-bba7-18b6601a2eb3'),(250,'Persons transfer out 6 months','number f persons transferred out 6 months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Persons transfer out 6 months\n number f persons transferred out 6 months\n \n 2018-10-16 14:19:33 UTC\n \n 2018-10-16 14:27: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 250\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-10-16 16:19:33',4,'2018-10-16 16:27:52',4,0,NULL,NULL,NULL,'ffbeae3c-4bc4-4321-a654-14378436f973'),(251,'Number with follow up CD4 6mnths','Number with follow up CD4 subset of net cohort 6mnths','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Number with follow up CD4 6mnths\n Number with follow up CD4 subset of net cohort 6mnths\n \n 2018-10-17 06:57:53 UTC\n \n 2018-10-18 14:41: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 251\n select distinct person_id \nfrom obs o \nwhere person_id in \n (select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 2249 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n union \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 4168 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n and person_id not in \n \n ( select person_id \n from obs o \n where o.concept_id = 2398 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n and location_id =:location \n and o.concept_id = 2256 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n \n;\n','2018-10-17 08:57:53',4,'2018-10-18 16:41:53',4,0,NULL,NULL,NULL,'efc3aa8f-0827-4d20-b258-6f8e819e3068'),(252,' New discordant couples who started ART',' New discordant couples who started ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New discordant couples who started ART\n New discordant couples who started ART\n \n 2018-10-17 16:17:34 UTC\n \n 2019-01-31 17:58: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 252\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2018-10-17 16:17:34',4,'2019-01-31 17:58:53',4,0,NULL,NULL,NULL,'830d6157-f04e-4f1e-bfa8-39f471518945'),(253,'Discordant couple','HIV+ person in discordant couple','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.NumericObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Discordant couple\n HIV+ person in discordant couple\n \n 2018-10-17 19:30:31 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n','2018-10-17 21:30:31',4,NULL,NULL,0,NULL,NULL,NULL,'85395524-996e-48a4-b8ec-148549099e39'),(254,'Number with follow up CD4 12mnths','Number with follow up CD4 12mnths','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Number with follow up CD4 12mnths\n Number with follow up CD4 12mnths\n \n 2018-10-18 13:53:50 UTC\n \n 2018-10-18 14:41: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 254\n select distinct person_id \nfrom obs o \nwhere person_id in \n (select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 2249 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n union \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 4168 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n ) \n and person_id not in \n \n ( select person_id \n from obs o \n where o.concept_id = 2398 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n ) \n and location_id =:location \n and o.concept_id = 2256 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n \n;\n','2018-10-18 15:53:50',4,'2018-10-18 16:41:08',4,0,NULL,NULL,NULL,'cbb4ec5e-947f-4c02-a46d-1d4d9cc1f28a'),(255,'Patients with follow up viral load 6 months','Patients with follow up viral load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Patients with follow up viral load 6 months\n Patients with follow up viral load\n \n 2018-10-18 13:58:41 UTC\n \n 2018-10-18 14:10: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 255\n select distinct person_id \nfrom obs o \nwhere person_id in \n ( \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 2249 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n union \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 4168 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \nand person_id not in \n ( \n select person_id \n from obs o \n where o.concept_id = 2398 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \nand location_id =:location \nand o.concept_id = 4186 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n;\n','2018-10-18 15:58:41',4,'2018-10-18 16:10:22',4,0,NULL,NULL,NULL,'a886ed5e-0e11-4590-9dd0-456e26e6669f'),(256,'Patients with follow up viral load 12 months','Patients with follow up viral load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Patients with follow up viral load 12 months\n Patients with follow up viral load\n \n 2018-10-18 14:42:51 UTC\n \n 2019-02-05 09:24: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 256\n select distinct person_id \nfrom obs o \nwhere person_id in \n ( \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 2249 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n union \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 4168 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \nand person_id not in \n ( \n select person_id \n from obs o \n where o.concept_id = 2398 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \nand location_id =:location \nand o.concept_id = 4186 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n;\n','2018-10-18 16:42:51',4,'2019-02-05 11:24:45',4,0,NULL,NULL,NULL,'77652a52-5c8c-46de-bf39-36b34fb3f0a7'),(257,'Clients lost to follow up 6months','Clients 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 Clients lost to follow up 6months\n Clients lost to follow up\n \n 2018-10-18 14:45:16 UTC\n \n 2018-10-18 14:45: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 257\n select distinct person_id \nfrom obs o \nwhere person_id in \n ( \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 2249 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n union \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 4168 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \nand person_id not in \n ( \n select person_id \n from obs o \n where o.concept_id = 2398 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \nand location_id =:location \nand o.concept_id = 2302 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n;\n','2018-10-18 16:45:16',4,'2018-10-18 16:45:57',4,0,NULL,NULL,NULL,'cc22e6d5-7614-4234-9241-861eac14b7e5'),(258,'Clients Dead 6 months','Clients Dead','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients Dead 6 months\n Clients Dead\n \n 2018-10-18 14:47:21 UTC\n \n 2018-10-18 14:49: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 258\n select distinct person_id \nfrom obs o \nwhere person_id in \n ( \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 2249 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n union \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 4168 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \nand person_id not in \n ( \n select person_id \n from obs o \n where o.concept_id = 2398 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \nand location_id =:location \nand o.concept_id = 3164 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n;\n','2018-10-18 16:47:21',4,'2018-10-18 16:49:03',4,0,NULL,NULL,NULL,'3b2f4c98-1621-4a1b-b352-95367ce251ca'),(259,'Clients Stopped 6 months','Clients Stopped ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients Stopped 6 months\n Clients Stopped \n \n 2018-10-18 14:50:25 UTC\n \n 2018-10-18 14:51: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 259\n select distinct person_id \nfrom obs o \nwhere person_id in \n ( \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 2249 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n union \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 4168 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \nand person_id not in \n ( \n select person_id \n from obs o \n where o.concept_id = 2398 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \nand location_id =:location \nand o.concept_id = 2300 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n;\n','2018-10-18 16:50:25',4,'2018-10-18 16:51:22',4,0,NULL,NULL,NULL,'5791856e-2f04-4eeb-980b-b151a820da7b'),(260,'Clients lost to follow up 12 months','Clients 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 Clients lost to follow up 12 months\n Clients lost to follow up\n \n 2018-10-18 14:52:40 UTC\n \n 2018-10-18 14: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 260\n select distinct person_id \nfrom obs o \nwhere person_id in \n ( \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 2249 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n union \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 4168 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n ) \nand person_id not in \n ( \n select person_id \n from obs o \n where o.concept_id = 2398 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n ) \nand location_id =:location \nand o.concept_id = 2302 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n;\n','2018-10-18 16:52:40',4,'2018-10-18 16:54:05',4,0,NULL,NULL,NULL,'6cd2d49e-36d2-40ed-857e-5b2e65e1fc16'),(261,'Clients Dead 12 months','Clients Dead','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients Dead 12 months\n Clients Dead\n \n 2018-10-18 14:55:18 UTC\n \n 2018-10-18 14:57: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 261\n select distinct person_id \nfrom obs o \nwhere person_id in \n ( \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 2249 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n union \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 4168 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n ) \nand person_id not in \n ( \n select person_id \n from obs o \n where o.concept_id = 2398 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n ) \nand location_id =:location \nand o.concept_id = 3164 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n;\n','2018-10-18 16:55:18',4,'2018-10-18 16:57:01',4,0,NULL,NULL,NULL,'ff4f67ac-f450-4d32-b964-d2a978bd9249'),(262,'Clients Stopped 12 months','Clients Stopped','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients Stopped 12 months\n Clients Stopped\n \n 2018-10-18 14:57:50 UTC\n \n 2018-10-18 14:59: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 262\n select distinct person_id \nfrom obs o \nwhere person_id in \n ( \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 2249 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n union \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 4168 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n ) \nand person_id not in \n ( \n select person_id \n from obs o \n where o.concept_id = 2398 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n ) \nand location_id =:location \nand o.concept_id = 2300 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n;\n','2018-10-18 16:57:50',4,'2018-10-18 16:59:34',4,0,NULL,NULL,NULL,'f24fd74d-6a99-4a66-81d7-c29f7bce2392'),(263,'Number still on original first line 6months','Number still on original first line','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Number still on original first line 6months\n Number still on original first line\n \n 2018-10-19 07:48:00 UTC\n \n 2018-10-19 07:56: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 263\n select distinct person_id \nfrom obs o \nwhere person_id in \n ( \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 2249 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n union \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 4168 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \nand person_id not in \n ( \n select person_id \n from obs o \n where o.concept_id = 2398 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \nand location_id =:location \nand o.concept_id in (3689,3691) \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n;\n','2018-10-19 09:48:00',4,'2018-10-19 09:56:34',4,0,NULL,NULL,NULL,'de663b24-02ce-4d61-b039-dc505ede607d'),(264,'Clients still on original first line 12 months','clients of original 1st line regimen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients still on original first line 12 months\n clients of original 1st line regimen\n \n 2018-10-19 08:09:03 UTC\n \n 2018-10-19 08:12: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 264\n select distinct person_id \nfrom obs o \nwhere person_id in \n ( \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 2249 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n union \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 4168 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n ) \nand person_id not in \n ( \n select person_id \n from obs o \n where o.concept_id = 2398 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n ) \nand location_id =:location \nand o.concept_id in (3689,3691) \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n;\n','2018-10-19 10:09:03',4,'2018-10-19 10:12:11',4,0,NULL,NULL,NULL,'490b6050-d002-47db-8214-0e48246f925d'),(265,'Clients on alternative 1st line ART 6months','Clients on alternative 1st line ART (switched)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients on alternative 1st line ART 6months\n Clients on alternative 1st line ART (switched)\n \n 2018-10-19 08:14:11 UTC\n \n 2018-10-19 08: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 265\n select distinct person_id \nfrom obs o \nwhere person_id in \n ( \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 2249 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n union \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 4168 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \nand person_id not in \n ( \n select person_id \n from obs o \n where o.concept_id = 2398 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \nand location_id =:location \nand o.concept_id in (3689,3691) AND o.concept_id = 2399 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n;\n','2018-10-19 10:14:11',4,'2018-10-19 10:16:57',4,0,NULL,NULL,NULL,'2e3d9aae-ab50-47e2-9c28-92726668cc78'),(266,'Clients on alternative 1st line ART 12 months','clients on alternative 1st line switched','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients on alternative 1st line ART 12 months\n clients on alternative 1st line switched\n \n 2018-10-19 08:21:27 UTC\n \n 2018-10-19 08:29: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 266\n select distinct person_id \nfrom obs o \nwhere person_id in \n ( \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 2249 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n union \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 4168 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n ) \nand person_id not in \n ( \n select person_id \n from obs o \n where o.concept_id = 2398 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n ) \nand location_id =:location \nand o.concept_id in (3689,3691) AND o.concept_id = 2399 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n;\n','2018-10-19 10:21:27',4,'2018-10-19 10:29:03',4,0,NULL,NULL,NULL,'dfb1ed02-163a-4814-b5d0-0c630fc969a5'),(267,'Clients switched to 2nd line 6months','swicthed second line','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients switched to 2nd line 6months\n swicthed second line\n \n 2018-10-19 08:34:22 UTC\n \n 2018-10-19 08:36: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 267\n select distinct person_id \nfrom obs o \nwhere person_id in \n ( \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 2249 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n union \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 4168 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \nand person_id not in \n ( \n select person_id \n from obs o \n where o.concept_id = 2398 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \nand location_id =:location \nand o.concept_id in (3692,3690) AND o.concept_id = 2399 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n;\n','2018-10-19 10:34:22',4,'2018-10-19 10:36:21',4,0,NULL,NULL,NULL,'a3ccbabd-a7c3-4bf6-af4a-a25ad0d0b8ec'),(268,'Clients switched to 2nd line 12 months','switched 2nd line','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients switched to 2nd line 12 months\n switched 2nd line\n \n 2018-10-19 08:37:24 UTC\n \n 2018-10-19 08:38: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 268\n select distinct person_id \nfrom obs o \nwhere person_id in \n ( \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 2249 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n union \n select person_id \n from obs o \n where location_id =:location \n and o.concept_id = 4168 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n ) \nand person_id not in \n ( \n select person_id \n from obs o \n where o.concept_id = 2398 \n and MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -12 MONTH)) \n ) \nand location_id =:location \nand o.concept_id in (3692,3690) AND o.concept_id = 2399 \nand MONTH(o.value_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n;\n','2018-10-19 10:37:24',4,'2018-10-19 10:38:19',4,0,NULL,NULL,NULL,'800b7890-ee58-47d4-9133-66bffe5400ba'),(269,'SQL ARV Regimen 2 or 3 months drug prescription in prev. 1 month','ARV Regimen 2 or 3 months drug prescription in previous 1 month SQL Cohort Query Version','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n SQL ARV Regimen 2 or 3 months drug prescription in prev. 1 month\n ARV Regimen 2 or 3 months drug prescription in previous 1 month SQL Cohort Query Version\n \n 2018-10-29 14:12:49 UTC\n \n 2018-10-30 10:06: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 269\n select distinct person_id \nfrom obs o \nwhere location_id =:location \nand (o.concept_id = 4174 and (o.value_coded = 4176 or o.value_coded = 4177)) \nand MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) and YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \nand o.voided = 0 \n \nand \n \nperson_id not in ( \nselect distinct person_id \nfrom obs os \nwhere os.location_id =:location \nand (os.concept_id = 3843 and os.value_coded = 3842) \nand MONTH(os.obs_datetime) = MONTH(DATE(:endDate)) and YEAR(os.obs_datetime) = YEAR(DATE(:endDate)) \n)\n','2018-10-29 16:12:49',4,'2018-10-30 12:06:37',4,0,NULL,NULL,NULL,'d987055f-14bb-4a9e-be79-050bba503637'),(270,'SQL ARV Regimen 3 months drug prescription in prev. 2 months','ARV Regimen 3 months drug prescription in previous 2 months SQL Cohort Query version','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n SQL ARV Regimen 3 months drug prescription in prev. 2 months\n ARV Regimen 3 months drug prescription in previous 2 months SQL Cohort Query version\n \n 2018-10-29 14:17:36 UTC\n \n 2018-10-30 10:07: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 270\n select distinct person_id \nfrom obs o \nwhere location_id =:location \nand o.concept_id = 4174 and o.value_coded = 4177 \nand MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) and YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \nand o.voided = 0 \n \nand \n \nperson_id not in ( \nselect distinct person_id \nfrom obs os \nwhere os.location_id =:location \nand (os.concept_id = 3843 and os.value_coded = 3842) \nand MONTH(os.obs_datetime) = MONTH(DATE(:endDate)) and YEAR(os.obs_datetime) = YEAR(DATE(:endDate)) \n)\n','2018-10-29 16:17:36',4,'2018-10-30 12:07:31',4,0,NULL,NULL,NULL,'98a1122a-d39d-4a67-bed0-7489dd29608d'),(271,'Tx. Curr. SQL Version with visits in previous 1 or 2 months and were given 2 or 3 months drug prescription','Tx. Curr. SQL Version with visits in previous 1 or 2 months and were given 2 or 3 months drug prescription','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Tx. Curr. SQL Version with visits in previous 1 or 2 months and were given 2 or 3 months drug prescription\n Tx. Curr. SQL Version with visits in previous 1 or 2 months and were given 2 or 3 months drug prescription\n \n 2018-10-29 14:18:41 UTC\n \n 2018-10-29 14:22: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 271\n SQL-ARV-Regimen-2-or-3-months-drug-prescription-in-prev.-1-month OR SQL-ARV-Regimen-3-months-drug-prescription-in-prev.-2-months\n \n \n SQL-ARV-Regimen-2-or-3-months-drug-prescription-in-prev.-1-month\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 SQL-ARV-Regimen-3-months-drug-prescription-in-prev.-2-months\n \n \n \n \n \n \n','2018-10-29 16:18:41',4,'2018-10-29 16:22:28',4,0,NULL,NULL,NULL,'f2af4f7d-643e-4ee6-93eb-74488cf98704'),(272,'Clients seen 1f','1f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 1f\n 1f\n \n 2018-10-30 08:31:02 UTC\n \n 2020-07-19 02:41: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 272\n select distinct o.person_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \n and o.concept_id = 3843 and o.value_coded in (3841, 3842) \n and month(obs_datetime) = month(cast(:endDate as date)) \n and year(obs_datetime) = year(cast(:endDate as date)) \n inner join person on person.person_id = o.person_id and person.voided = 0 and o.voided = 0 \n \nwhere (o.location_id = :location or parent_location = :location) \n and o.person_id in ( \n-- CLIENTS GIVEN 1F \n select distinct os.person_id \n from obs os \n where os.obs_datetime BETWEEN :startDate AND :endDate \n and os.concept_id = 2250 and os.value_coded = 2207 \n ) \n and o.person_id not in ( \n select distinct os.person_id AS Id \n from obs os \n where os.concept_id = 2249 \n and os.value_datetime between :startDate and :endDate \n and os.voided = 0 \n ) \n and o.person_id not in ( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n and date(os.obs_datetime) between :startDate and :endDate) \n and o.person_id not in \n -- EXCLUDE DECEASED \n (select distinct person_id \n from person \n where death_date < cast(:endDate as date) \n and dead = 1)\n','2018-10-30 08:31:02',4,'2020-07-19 02:41:07',4,0,NULL,NULL,NULL,'55df743e-4818-40e3-9df4-f76db645b660'),(273,'Clients multi month 1f','1f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 1f\n 1f\n \n 2018-10-30 08:55:29 UTC\n \n 2019-05-09 09:02: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 273\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2207 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2207 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2207 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2207 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2207 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2207 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2207 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2207 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2207 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2207 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2207 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2018-10-30 08:55:29',4,'2019-05-09 09:02:12',4,0,NULL,NULL,NULL,'a018ec2e-bf15-49cb-96e2-cbfe9201211e'),(274,'CMP_ART Regimen 1month supply 6e','6e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 6e\n 6e\n \n 2018-10-30 09:01:24 UTC\n \n 2021-01-28 01:43: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 274\n Clients-seen-given-1-month-supply-6e OR Clients-newly-initiated-6e\n \n \n Clients-seen-given-1-month-supply-6e\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 Clients-newly-initiated-6e\n \n \n \n \n \n \n','2018-10-30 09:01:24',4,'2021-01-28 01:43:24',4,0,NULL,NULL,NULL,'af784bca-5138-4cb1-9f88-83a571d00101'),(275,'Clients seen 1c ','1c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 1c \n 1c\n \n 2019-01-09 23:00:14 UTC\n \n 2019-05-08 07:50: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 275\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2201 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date < :endDate \n and dead = 1 \n ) \n \n \n','2019-01-09 23:00:14',4,'2019-05-08 07:50:10',4,0,NULL,NULL,NULL,'cc807875-4872-45bc-9b92-f1d98ed9c1c9'),(276,'Clients seen 1d','1d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 1d\n 1d\n \n 2019-01-09 23:06:41 UTC\n \n 2019-05-08 08:07: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 276\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2203 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-01-09 23:06:41',4,'2019-05-08 08:07:00',4,0,NULL,NULL,NULL,'9d433224-b4de-4540-b350-c3ef93507f1e'),(277,'Clients seen 1e','1e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 1e\n 1e\n \n 2019-01-09 23:10:05 UTC\n \n 2019-05-08 08:08: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 277\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2205 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-01-09 23:10:05',4,'2019-05-08 08:08:46',4,0,NULL,NULL,NULL,'c08132fe-9f08-4c82-a42c-3228fa855d5c'),(278,'Clients seen 1g','1g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 1g\n 1g\n \n 2019-01-09 23:11:31 UTC\n \n 2019-05-08 08:12: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 278\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3672 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-01-09 23:11:31',4,'2019-05-08 08:12:38',4,0,NULL,NULL,NULL,'5e7ddc90-35bd-44be-b561-9b0887891e67'),(279,'Clients seen 1h','1h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 1h\n 1h\n \n 2019-01-09 23:12:35 UTC\n \n 2019-05-08 08:13: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 279\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3673 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-01-09 23:12:35',4,'2019-05-08 08:13:49',4,0,NULL,NULL,NULL,'3db0f8da-5cfd-460e-a6b3-c0990a276802'),(280,'Clients seen 2c','2c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 2c\n 2c\n \n 2019-01-09 23:17:52 UTC\n \n 2019-05-08 09:58: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 280\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2210 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-01-09 23:17:52',4,'2019-05-08 09:58:10',4,0,NULL,NULL,NULL,'5b37bb40-282b-4d97-9981-a3d8198b8627'),(281,'Clients seen 2d','2d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 2d\n 2d\n \n 2019-01-09 23:18:59 UTC\n \n 2019-05-08 10:03: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 281\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-01-09 23:18:59',4,'2019-05-08 10:03:25',4,0,NULL,NULL,NULL,'649d5831-2887-4080-bcff-6a71897413a2'),(282,'Clients seen 2e','2e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 2e\n 2e\n \n 2019-01-09 23:20:18 UTC\n \n 2019-05-08 10:04: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 282\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-01-09 23:20:18',4,'2019-05-08 10:04:34',4,0,NULL,NULL,NULL,'60e76070-aea0-4257-ae5a-a954455d9e99'),(283,'Clients seen 2f','2f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 2f\n 2f\n \n 2019-01-09 23:22:24 UTC\n \n 2019-05-08 10: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 283\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-01-09 23:22:24',4,'2019-05-08 10:05:36',4,0,NULL,NULL,NULL,'8c729f10-ec54-45b3-aea2-aeb95a4c3694'),(284,'Clients seen 2g','2g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 2g\n 2g\n \n 2019-01-09 23:30:40 UTC\n \n 2019-05-08 10: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 284\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-01-09 23:30:40',4,'2019-05-08 10:10:12',4,0,NULL,NULL,NULL,'5f942d03-1351-4fc6-8617-f64ab62eba7a'),(285,'Clients seen 2h','2h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 2h\n 2h\n \n 2019-01-09 23:32:06 UTC\n \n 2019-05-08 10:13: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 285\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-01-09 23:32:06',4,'2019-05-08 10:13:08',4,0,NULL,NULL,NULL,'a7416bdd-ffb1-4658-afb2-1e646a52ebf4'),(286,'Clients multi month 1c','1c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 1c\n 1c\n \n 2019-01-09 23:49:58 UTC\n \n 2019-05-09 09:09: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 286\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2201 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2201 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2201 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2201 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2201 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2201 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2201 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2201 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2201 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2201 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2201 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-09 23:49:58',4,'2019-05-09 09:09:54',4,0,NULL,NULL,NULL,'128fe28c-9f9b-494c-a220-314433181501'),(287,'Clients multi month 1d','1d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 1d\n 1d\n \n 2019-01-09 23:54:38 UTC\n \n 2019-05-09 09:11: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 287\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2203 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2203 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2203 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2203 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2203 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2203 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2203 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2203 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2203 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2203 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2203 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-09 23:54:38',4,'2019-05-09 09:11:37',4,0,NULL,NULL,NULL,'6591b115-2cd0-42ef-ab14-d4c229ed05e8'),(288,'Clients multi month 1e','1e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 1e\n 1e\n \n 2019-01-09 23:56:11 UTC\n \n 2019-05-09 09:12: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 288\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2205 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2205 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2205 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2205 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2205 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2205 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2205 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2205 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2205 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2205 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2205 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-09 23:56:11',4,'2019-05-09 09:12:55',4,0,NULL,NULL,NULL,'2bee1266-3b05-4cd1-9eaa-3a9dce01ed06'),(289,'Clients multi month 1g','1g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 1g\n 1g\n \n 2019-01-09 23:57:13 UTC\n \n 2019-05-09 09:17: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 289\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3672 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3672 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3672 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3672 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3672 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3672 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3672 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3672 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3672 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3672 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3672 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-09 23:57:13',4,'2019-05-09 09:17:19',4,0,NULL,NULL,NULL,'894b729d-bded-4fa0-b54e-30a379dc4927'),(290,'Clients multi month 1h','1h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 1h\n 1h\n \n 2019-01-09 23:58:17 UTC\n \n 2019-05-09 09:43: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 290\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3673 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3673 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3673 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3673 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3673 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3673 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3673 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3673 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3673 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3673 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3673 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-09 23:58:17',4,'2019-05-09 09:43:44',4,0,NULL,NULL,NULL,'2e5a0852-2047-4c6e-be30-d19665f1f838'),(291,'Clients multi month 2c','2c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 2c\n 2c\n \n 2019-01-10 00:00:16 UTC\n \n 2019-05-09 09:27: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 291\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2210 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2210 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2210 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2210 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2210 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2210 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2210 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2210 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2210 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2210 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2210 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-10 00:00:16',4,'2019-05-09 09:27:52',4,0,NULL,NULL,NULL,'dc0406d3-2c3c-4157-ae83-537ae4e65e59'); -INSERT INTO `serialized_object` VALUES (292,'Clients multi month 2d','2d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 2d\n 2d\n \n 2019-01-10 00:01:21 UTC\n \n 2019-05-09 09:29: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 292\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-10 00:01:21',4,'2019-05-09 09:29:04',4,0,NULL,NULL,NULL,'4452e974-8c6e-442e-bb45-d6e09d26765a'),(293,'Clients multi month 2e','2e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 2e\n 2e\n \n 2019-01-10 00:02:30 UTC\n \n 2019-05-09 09:30: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 293\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-10 00:02:30',4,'2019-05-09 09:30:24',4,0,NULL,NULL,NULL,'b70551ca-7dda-4d71-be21-852530c01b27'),(294,'Clients multi month 2f','2f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 2f\n 2f\n \n 2019-01-10 00:04:54 UTC\n \n 2019-05-09 09:31: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 294\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-10 00:04:54',4,'2019-05-09 09:31:55',4,0,NULL,NULL,NULL,'7b572190-3a8e-41fd-9f13-b857c5a2d5a6'),(295,'Clients multi month 2g','2g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 2g\n 2g\n \n 2019-01-10 00:05:54 UTC\n \n 2019-05-09 09:32: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 295\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-10 00:05:54',4,'2019-05-09 09:32:54',4,0,NULL,NULL,NULL,'5aa75e1d-5ae4-47d7-9b0b-e099ecdfbde9'),(296,'Clients multi month 2h','2h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 2h\n 2h\n \n 2019-01-10 00:06:48 UTC\n \n 2019-05-09 09: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 296\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-10 00:06:48',4,'2019-05-09 09:34:00',4,0,NULL,NULL,NULL,'e008404a-b1f1-442a-b667-5590a15ed2e9'),(297,'Clients multi month 3a','3a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 3a\n 3a\n \n 2019-01-10 00:08:01 UTC\n \n 2019-05-09 09:38: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 297\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-10 00:08:01',4,'2019-05-09 09:38:07',4,0,NULL,NULL,NULL,'88b2c868-7a1f-49e1-9277-e8dc122cafdd'),(298,'Clients multi month 3b','3b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 3b\n 3b\n \n 2019-01-10 00:09:34 UTC\n \n 2019-05-09 09:39: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 298\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-10 00:09:34',4,'2019-05-09 09:39:22',4,0,NULL,NULL,NULL,'c3243091-3cc9-4c2d-94d8-0b3c1b7c226a'),(299,'Clients seen 3a','3a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 3a\n 3a\n \n 2019-01-10 00:11:14 UTC\n \n 2019-05-08 10:25: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 299\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-01-10 00:11:14',4,'2019-05-08 10:25:34',4,0,NULL,NULL,NULL,'f635e506-399a-49f2-8016-c9b3410fb65d'),(300,'Clients seen 3b','3b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 3b\n 3b\n \n 2019-01-10 00:12:05 UTC\n \n 2019-05-08 10:37: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 300\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-01-10 00:12:05',4,'2019-05-08 10:37:48',4,0,NULL,NULL,NULL,'56b9db93-8aab-4bb7-9296-06b385249737'),(309,'CMP_ART Regimen 1month supply 6b','6b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 6b\n 6b\n \n 2019-01-10 16:41:42 UTC\n \n 2021-01-28 01: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 309\n Clients-seen-given-1-month-supply-6b OR Clients-newly-initiated-6b\n \n \n Clients-seen-given-1-month-supply-6b\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 Clients-newly-initiated-6b\n \n \n \n \n \n \n','2019-01-10 16:41:42',4,'2021-01-28 01:22:44',4,0,NULL,NULL,NULL,'36e870b9-ea69-42f4-af1c-ab0dc12652d1'),(310,'CMP_ART Regimen 1month supply 6c','6c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 6c\n 6c\n \n 2019-01-10 16:51:23 UTC\n \n 2021-01-28 01:29: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 310\n Clients-seen-given-1-month-supply-6c OR Clients-newly-initiated-6c\n \n \n Clients-seen-given-1-month-supply-6c\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 Clients-newly-initiated-6c\n \n \n \n \n \n \n','2019-01-10 16:51:23',4,'2021-01-28 01:29:53',4,0,NULL,NULL,NULL,'ab5ee2c6-b62a-4730-ab20-93402f758aba'),(311,'CMP_ART Regimen 1month supply 6d','6d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 6d\n 6d\n \n 2019-01-10 17:18:53 UTC\n \n 2021-01-28 01:36: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 311\n Clients-seen-given-1-month-supply-6d OR Clients-newly-initiated-6d\n \n \n Clients-seen-given-1-month-supply-6d\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 Clients-newly-initiated-6d\n \n \n \n \n \n \n','2019-01-10 17:18:53',4,'2021-01-28 01:36:27',4,0,NULL,NULL,NULL,'6fab4ceb-75e5-4687-ab3d-96d87493c83c'),(312,'CMP_ART Regimen 1month supply 6f','6f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 6f\n 6f\n \n 2019-01-10 17:30:56 UTC\n \n 2021-01-28 01:47: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 312\n Clients-newly-initiated-6f OR Clients-seen-given-1-month-supply-6f\n \n \n Clients-newly-initiated-6f\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 Clients-seen-given-1-month-supply-6f\n \n \n \n \n \n \n','2019-01-10 17:30:56',4,'2021-01-28 01:47:31',4,0,NULL,NULL,NULL,'5b53d187-636a-4b70-9d6a-56be8a998fe5'),(313,'CMP_ART Regimen 1month supply 5h','5h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 5h\n 5h\n \n 2019-01-10 17:40:48 UTC\n \n 2021-01-28 01:08: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 313\n Clients-newly-initiated-5h OR Clients-seen-given-1-month-supply-5h\n \n \n Clients-newly-initiated-5h\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 Clients-seen-given-1-month-supply-5h\n \n \n \n \n \n \n','2019-01-10 17:40:48',4,'2021-01-28 01:08:05',4,0,NULL,NULL,NULL,'817075e8-f801-429c-8ffa-b5b9ce9967ff'),(314,'CMP_ART Regimen 1month supply 4g','4g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4g\n 4g\n \n 2019-01-10 17:54:49 UTC\n \n 2021-01-27 23:58: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 314\n Clients-newly-initiated-4g OR Clients-seen-given-1-month-supply-4g\n \n \n Clients-newly-initiated-4g\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 Clients-seen-given-1-month-supply-4g\n \n \n \n \n \n \n','2019-01-10 17:54:49',4,'2021-01-27 23:58:55',4,0,NULL,NULL,NULL,'41d660e4-321c-42e4-995f-073161a5a1f0'),(315,'CMP_ART Regimen 1month supply 4h','4h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4h\n 4h\n \n 2019-01-10 18:05:16 UTC\n \n 2021-01-28 00:02: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 315\n Clients-newly-initiated-4h OR Clients-seen-given-1-month-supply-4h\n \n \n Clients-newly-initiated-4h\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 Clients-seen-given-1-month-supply-4h\n \n \n \n \n \n \n','2019-01-10 18:05:16',4,'2021-01-28 00:02:33',4,0,NULL,NULL,NULL,'0f5b1812-4fd6-4ded-b64e-16def8e64d81'),(316,'CMP_ART Regimen 1month supply 4j','4j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4j\n 4j\n \n 2019-01-10 18:17:31 UTC\n \n 2021-01-28 00:08: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 316\n Clients-newly-initiated-4j OR Clients-seen-given-1-month-supply-4j\n \n \n Clients-newly-initiated-4j\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 Clients-seen-given-1-month-supply-4j\n \n \n \n \n \n \n','2019-01-10 18:17:31',4,'2021-01-28 00:08:32',4,0,NULL,NULL,NULL,'9f6b4f25-5941-4798-ac05-75721fc60f5a'),(317,'CMP_ART Regimen 1month supply 4k','4k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4k\n 4k\n \n 2019-01-10 18:25:53 UTC\n \n 2021-01-28 00:14: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 317\n Clients-newly-initiated-4k OR Clients-seen-given-1-month-supply-4k\n \n \n Clients-newly-initiated-4k\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 Clients-seen-given-1-month-supply-4k\n \n \n \n \n \n \n','2019-01-10 18:25:53',4,'2021-01-28 00:14:25',4,0,NULL,NULL,NULL,'edfa3d6d-49de-4b92-80e3-06fbf1ac7064'),(318,'CMP_ART Regimen 1month supply 5c','5c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 5c\n 5c\n \n 2019-01-10 18:32:59 UTC\n \n 2021-01-28 00:32: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 318\n Clients-seen-given-1-month-supply-5c OR Clients-newly-initiated-5c\n \n \n Clients-seen-given-1-month-supply-5c\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 Clients-newly-initiated-5c\n \n \n \n \n \n \n','2019-01-10 18:32:59',4,'2021-01-28 00:32:35',4,0,NULL,NULL,NULL,'e7054506-95ba-4086-8f65-bd053e845fcf'),(319,'CMP_ART Regimen 1month supply 5d','5d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 5d\n 5d\n \n 2019-01-10 18:40:05 UTC\n \n 2021-01-28 00: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 319\n Clients-seen-given-1-month-supply-5d OR Clients-newly-initiated-5d\n \n \n Clients-seen-given-1-month-supply-5d\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 Clients-newly-initiated-5d\n \n \n \n \n \n \n','2019-01-10 18:40:05',4,'2021-01-28 00:37:52',4,0,NULL,NULL,NULL,'78bbfb25-ec26-40c2-8077-f300dabe0a0f'),(320,'CMP_ART Regimen 1month supply 5e','5e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 5e\n 5e\n \n 2019-01-10 18:44:24 UTC\n \n 2021-01-28 00:45: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 320\n Clients-newly-initiated-5e OR Clients-seen-given-1-month-supply-5e\n \n \n Clients-newly-initiated-5e\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 Clients-seen-given-1-month-supply-5e\n \n \n \n \n \n \n','2019-01-10 18:44:24',4,'2021-01-28 00:45:23',4,0,NULL,NULL,NULL,'4efdb85c-372c-4623-808d-7c9bc93eeff1'),(321,'CMP_ART Regimen 1month supply 5f','5f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 5f\n 5f\n \n 2019-01-10 18:49:28 UTC\n \n 2021-01-28 00:49: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 321\n Clients-newly-initiated-5f OR Clients-seen-given-1-month-supply-5f\n \n \n Clients-newly-initiated-5f\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 Clients-seen-given-1-month-supply-5f\n \n \n \n \n \n \n','2019-01-10 18:49:28',4,'2021-01-28 00:49:51',4,0,NULL,NULL,NULL,'2b09727b-e984-4c6f-841b-6e73c973622c'),(322,'Clients enroled on PreART exlcuding those with an ART start date','Combines client enrolled on PreART and excludes clients with an ART start date before end of period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients enroled on PreART exlcuding those with an ART start date\n Combines client enrolled on PreART and excludes clients with an ART start date before end of period\n \n 2019-01-23 08:29:09 UTC\n \n 2019-01-23 08:45: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 java.util.List\n true\n \n \n 322\n Date-enrolled-in-Pre-ART AND Clients-ever-enrolled-on-ART\n \n \n Date-enrolled-in-Pre-ART\n \n \n \n \n locationList\n ${location}\n \n \n value2\n ${endDate}\n \n \n value1\n ${startDate}\n \n \n \n \n \n Clients-ever-enrolled-on-ART\n \n \n \n \n locationList\n ${location}\n \n \n value1\n ${endDate}\n \n \n \n \n \n','2019-01-23 10:29:09',4,'2019-01-23 10:45:31',4,0,NULL,NULL,NULL,'1feca9b1-e0d7-4c4e-b898-0dc32b0cc71b'),(323,'CITest33: Clients enrolled on PreART','Testing','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITest33: Clients enrolled on PreART\n Testing\n \n 2019-01-23 08:37:15 UTC\n \n 2019-01-23 08:38: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 java.util.List\n true\n \n \n 323\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-01-23 10:37:15',4,'2019-01-23 10:38:29',4,0,NULL,NULL,NULL,'2e5bfe4e-6d66-4087-80db-71b46d544763'),(325,'Test Client Enrolled in PreART Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Test Client Enrolled in PreART Data Set\n \n 2019-01-23 08:39:18 UTC\n \n 2019-03-26 13:22: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 325\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 TXCurrPrev\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 20to24yrs\n \n \n \n \n \n','2019-01-23 08:39:18',4,'2019-03-26 13:22:19',4,0,NULL,NULL,NULL,'127b8507-13c4-4484-8957-880f8a03fbfd'),(326,'Pre-ART clients seen in previous months','preart multi month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pre-ART clients seen in previous months\n preart multi month\n \n 2019-01-23 10:54:36 UTC\n \n 2019-01-23 10:54: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 326\n','2019-01-23 12:54:36',4,'2019-01-23 12:54:46',4,0,NULL,NULL,NULL,'9becf662-98cd-4606-bbb2-e8dffabf1be0'),(328,'Clients not seen for unknown reasons','defaulters and missed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients not seen for unknown reasons\n defaulters and missed\n \n 2019-01-23 13:50:54 UTC\n \n 2019-02-03 11:02:39 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n 328\n ART-clients-with-Missed-Appointments OR ART-clients-who-Defaulted\n \n \n ART-clients-with-Missed-Appointments\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 ART-clients-who-Defaulted\n \n \n \n \n \n \n','2019-01-23 13:50:54',4,'2019-02-03 11:02:39',4,0,NULL,NULL,NULL,'b97be60d-0f0b-44bc-a6e6-fa57577e7889'),(329,'PreART Clients not initiated on ART','enrolled but no ART start date','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PreART Clients not initiated on ART\n enrolled but no ART start date\n \n 2019-01-24 12:41:36 UTC\n \n 2019-01-24 13:04:43 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 329\n select distinct 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.concept_id = 2223 \nand person_id not in ( \n select distinct person_id \n from obs os inner join location l on os.location_id = l.location_id \n where (os.location_id =:location or parent_location =:location) \n and os.concept_id = 2249 \n )\n','2019-01-24 12:41:36',4,'2019-01-24 13:04:43',4,0,NULL,NULL,NULL,'d0381567-7eab-475a-8525-9d9bd207ea6d'),(330,'New Persons enrolled in Pre ART','enrolled and no art start','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New Persons enrolled in Pre ART\n enrolled and no art start\n \n 2019-01-24 13:57:17 UTC\n \n 2019-01-31 20:30: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 330\n PreART-Clients-not-initiated-on-ART AND Date-enrolled-in-Pre-ART\n \n \n PreART-Clients-not-initiated-on-ART\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n \n \n \n Date-enrolled-in-Pre-ART-SQL\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','2019-01-24 13:57:17',4,'2019-01-31 20:30:08',4,0,NULL,NULL,NULL,'e7aaf7be-3ce1-4d84-9e78-2da603a5961f'),(331,'clients given multi month ARVs 2 or 3mnths','clients given multi month ARVs 2 or 3mnths','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients given multi month ARVs 2 or 3mnths\n clients given multi month ARVs 2 or 3mnths\n \n 2019-01-29 21:03:46 UTC\n \n 2019-03-29 07:50: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 331\n select distinct Id from \n (select distinct Id from \n ( \n (select distinct o.person_id AS 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 = 2250 \n and o.value_coded in (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n and o.voided = 0 \n and obs_datetime BETWEEN :startDate and DATE_ADD(:endDate, INTERVAL 1 DAY) \n ) \n \n UNION \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -28 DAY)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -28 DAY)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175,4176.4177,4245,4246,4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -28 DAY)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -28 DAY)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id = :location or parent_location = :location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE ( o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded in (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n ) \n) as regimen \nwhere Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 AND obs_datetime < DATE_ADD(:endDate, INTERVAL 1 DAY)) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate, INTERVAL 1 DAY) \n and dead = 1 \n ) \n )as final\n','2019-01-29 21:03:46',4,'2019-03-29 07:50:08',4,0,NULL,NULL,NULL,'c8709121-d393-4861-b808-559fd29dfd7d'),(332,'clients given multi month ARVs 3mnths','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients given multi month ARVs 3mnths\n \n \n 2019-01-29 21:28:52 UTC\n \n 2019-03-29 07:53: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 332\n select distinct Id from \n(select id from \n ( \n ( \n select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n ) \n \n UNION \n \n ( \n select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n ) \n \n UNION \n \n ( \n select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n ) \n \n UNION \n \n ( \n select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n ) \n \n UNION \n \n ( \n select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n ) \n \n UNION \n \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in(4175,4146,4177,4245,4246,4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id = :location or parent_location = :location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n \n ) \n \nUNION \n \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in(4175,4146,4177,4245,4246,4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id = :location or parent_location = :location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n \n ) \n \nUNION \n \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in(4175,4146,4177,4245,4246,4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id = :location or parent_location = :location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n \n ) \n \nUNION \n \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in(4175,4146,4177,4245,4246,4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id = :location or parent_location = :location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n \n ) \n \nUNION \n \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in(4175,4146,4177,4245,4246,4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id = :location or parent_location = :location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n \n ) \n \nUNION \n \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(DATE_ADD(:endDate,INTERVAL 1 DAY), INTERVAL -28 DAY)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(DATE_ADD(:endDate,INTERVAL 1 DAY), INTERVAL -28 DAY)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in(4175,4146,4177,4245,4246,4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id = :location or parent_location = :location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n \n ) \n) as regimen \n \nwhere Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 AND obs_datetime < :endDate) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < :endDate \n and dead = 1 \n ) \n) \nas final\n','2019-01-29 21:28:52',4,'2019-03-29 07:53:17',4,0,NULL,NULL,NULL,'4cdbc901-cea1-4995-84b6-0b6d46c49e03'),(333,'Appointment NOT scheduled','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Appointment NOT scheduled\n \n \n 2019-01-29 21:45:38 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n NOT_IN\n \n \n \n','2019-01-29 21:45:38',4,NULL,NULL,0,NULL,NULL,NULL,'b3da29d2-311a-4264-bef4-5b1b0629704e'),(334,'Clients who picked up ARVs on time','Clients who picked up ARVs on time','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients who picked up ARVs on time\n Clients who picked up ARVs on time\n \n 2019-01-29 21:46:50 UTC\n \n 2019-03-29 08: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 334\n Clients-given-2weeks-ARV OR clients-given-multi-month-ARVs-3mnths OR clients-given-multi-month-ARVs-2-or-3mnths AND Clients-with-scheduled-appointments-SQL\n \n \n Clients-given-2weeks-ARV\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 clients-given-multi-month-ARVs-3mnths\n \n \n \n \n \n \n clients-given-multi-month-ARVs-2-or-3mnths\n \n \n \n \n \n \n Clients-with-scheduled-appointments-SQL\n \n \n \n \n \n \n','2019-01-29 21:46:50',4,'2019-03-29 08:00:58',4,0,NULL,NULL,NULL,'937a56fd-e654-414a-b1bb-9499ba8d99e5'),(335,'clients not on appointement','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients not on appointement\n \n \n 2019-01-29 21:53:00 UTC\n \n 2019-01-29 21:54: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 335\n COUNT\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n','2019-01-29 21:53:00',4,'2019-01-29 21:54:40',4,0,NULL,NULL,NULL,'eb1bf76e-95e8-474d-b856-05c69ce9bcdd'),(336,'clients given 2 or 3mnths ARVs','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients given 2 or 3mnths ARVs\n \n \n 2019-01-29 21:55:47 UTC\n \n 2019-01-29 21:56: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 336\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-01-29 21:55:47',4,'2019-01-29 21:56:53',4,0,NULL,NULL,NULL,'3c92647f-a1dd-4218-b440-3272663aa92d'),(337,'clients given 3mnths ARVs ','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients given 3mnths ARVs \n \n \n 2019-01-29 21:57:48 UTC\n \n 2019-01-29 21:58: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 337\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-01-29 21:57:48',4,'2019-01-29 21:58:37',4,0,NULL,NULL,NULL,'a4a2ee04-3761-40c9-b9b9-962fa502780d'),(338,'Clients on appointment','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients on appointment\n \n \n 2019-01-29 22:00:24 UTC\n \n 2019-01-29 22:01: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 338\n COUNT\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n','2019-01-29 22:00:24',4,'2019-01-29 22:01:08',4,0,NULL,NULL,NULL,'dc060565-40ef-4a71-b515-28cd018fb5d6'),(339,'Discordant couples SQL','Discordant couples','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Discordant couples SQL\n Discordant couples\n \n 2019-01-31 04:56:06 UTC\n \n 2019-01-31 05:06: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 339\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.concept_id = 4225 and o.value_coded = 2146\n','2019-01-31 04:56:06',4,'2019-01-31 05:06:40',4,0,NULL,NULL,NULL,'b3b772a7-7fc2-40d4-bbaa-8fe6e5eb9bd9'),(340,'ART Start date SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART Start date SQL\n \n \n 2019-01-31 08:49:55 UTC\n \n 2022-05-19 08:30: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 340\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 \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 NEWLY INITIATED ON ART \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 and o.voided = 0 \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 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 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.Age)\n','2019-01-31 08:49:55',4,'2022-05-19 08:30:24',4,0,NULL,NULL,NULL,'6f37715f-711c-48fa-8f56-e3360233d885'),(341,'ART restart date SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART restart date SQL\n \n \n 2019-01-31 09:40:55 UTC\n \n 2022-04-27 11:03: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 341\n select distinct o.person_id \nfrom obs o \n-- PATIENTS WITH NO CLINICAL CONTACT OR ARV PICK-UP FOR GREATER THAN 28 DAYS \n-- SINCE THEIR LAST EXPECTED CONTACT WHO RESTARTED ARVs WITHIN THE REPORTING PERIOD \ninner join location l on o.location_id = l.location_id \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND patient.voided = 0 AND o.voided = 0 \nAND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n \n -- Client Seen: As either patient OR Treatment Buddy \n AND ( \n o.person_id 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 \n ) \n \n -- Client Seen and Date Restarted picked \n OR o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 3708 AND os.value_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n ) \n -- Still on treatment at the end of the reporting period \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime >= cast(:startDate as DATE) and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) <= 28) as Still_On_Treatment_End_Period \n ) \n \n -- Transfered Out to Another Site during their latest encounter before the start date \n AND o.person_id not in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS last_obs_tout \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 4155 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having last_obs_tout = 2146) as Transfered_Out_In_Last_Encounter \n ) \n \n-- NOT Transfered In from another Site \n AND o.person_id not in ( \n select os.person_id \n from obs os \n where (os.concept_id = 2253 AND DATE(os.value_datetime) BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE)) \n AND os.voided = 0 \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 \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 \nWHERE (o.location_id =:location or parent_location =:location) \n\n','2019-01-31 09:40:55',4,'2022-04-27 11:03:30',4,0,NULL,NULL,NULL,'f1a22112-f4e3-47eb-a3c8-beff0cc47bd4'),(342,'ART clients seen SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients seen SQL\n \n \n 2019-01-31 10:45:08 UTC\n \n 2024-02-15 09:25: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 342\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 \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 NEWLY INITIATED ON ART \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 and o.voided = 0 \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 ) \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 -7 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 \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 -7 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 \n and o.voided = 0 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n \n) \n \nORDER BY Clients_Seen.Age) \n\n','2019-01-31 16:15:08',4,'2024-02-15 14:55:27',4,0,NULL,NULL,NULL,'092398d1-86b9-4486-97ff-2864ef7871e9'),(343,'ART Clients transferred in SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART Clients transferred in SQL\n \n \n 2019-01-31 10:53:28 UTC\n \n 2022-04-28 13:11: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 343\n select distinct o.person_id \nfrom obs o \nwhere o.concept_id = 2253 and o.voided = 0 \nand MONTH(o.value_datetime) = MONTH(CAST(:endDate AS DATE)) \nand YEAR(o.value_datetime) = YEAR(CAST(:endDate AS DATE))\n','2019-01-31 10:53:28',4,'2022-04-28 13:11:52',4,0,NULL,NULL,NULL,'08280ca8-e857-4730-8350-950ab55aee95'),(344,'ART Clients transferred out SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART Clients transferred out SQL\n \n \n 2019-01-31 11:08:01 UTC\n \n 2022-08-25 10:12: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 344\n SELECT ID \n FROM \n ( \n select active_clients.person_id as 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 -- Patient Register \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 -- Follow-up date \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 MONTH (active_clients.latest_follow_up) = MONTH(cast(:endDate as date)) \n and YEAR (active_clients.latest_follow_up) = YEAR(cast(:endDate as date)) \n and DATEDIFF(CAST(:endDate AS DATE),latest_follow_up) >= 1 \n \n ) AS NOT_ACTIVE \nINNER JOIN \n \n( \n select B.person_id, B.obs_group_id \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 -- HIV Treatment and Care Progress Template \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 -- Transferred out \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n \n \n \n) AS TOUTS \non TOUTS.person_id = NOT_ACTIVE.ID \n \nAND NOT_ACTIVE.ID not in ( \n -- Died \n select distinct person_id \n from person \n where death_date <= CAST('2022-03-31' AS DATE) \n and dead = 1 \n \n ) \n\n','2019-01-31 11:08:01',4,'2022-08-25 10:12:07',4,0,NULL,NULL,NULL,'ab08b4d3-0971-427c-b3e9-8784299dbee7'),(345,'Tx Curr Previous months SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Tx Curr Previous months SQL\n \n \n 2019-01-31 11:21:16 UTC\n \n 2019-01-31 11: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 345\n clients-given-multi-month-ARVs-3mnths OR clients-given-multi-month-ARVs-2-or-3mnths\n \n \n clients-given-multi-month-ARVs-3mnths\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 clients-given-multi-month-ARVs-2-or-3mnths\n \n \n \n \n \n \n','2019-01-31 11:21:16',4,'2019-01-31 11:24:10',4,0,NULL,NULL,NULL,'9563340e-e1d1-4725-bff2-e89edbf454e2'),(346,'Clients given CTX SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given CTX SQL\n \n \n 2019-01-31 19:15:31 UTC\n \n 2019-02-03 11:38: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 346\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.concept_id = 3728 \nand o.value_numeric < 31 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate \n\n','2019-01-31 19:15:31',4,'2019-02-03 11:38:00',4,0,NULL,NULL,NULL,'e0ae8042-353d-41e9-a70f-4df0c6bcf58b'),(347,'Pre-ART Clients seen','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pre-ART Clients seen\n \n \n 2019-01-31 19:45:15 UTC\n \n 2019-01-31 20:04: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 347\n PreART-Clients-not-initiated-on-ART AND ART-clients-seen-SQL\n \n \n PreART-Clients-not-initiated-on-ART\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n \n \n \n ART-clients-seen-SQL\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','2019-01-31 19:45:15',4,'2019-01-31 20:04:38',4,0,NULL,NULL,NULL,'66c8ee04-f791-4774-84f7-597e039a4f94'),(348,'Date Confirmed HIV positive SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Date Confirmed HIV positive SQL\n \n \n 2019-01-31 20:09:36 UTC\n \n 2019-01-31 20:10: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 348\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.concept_id = 2222 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2019-01-31 20:09:36',4,'2019-01-31 20:10:20',4,0,NULL,NULL,NULL,'209fc83a-9c42-44aa-afe2-583e6e19cb56'),(349,'Date enrolled in Pre-ART SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Date enrolled in Pre-ART SQL\n \n \n 2019-01-31 20:24:03 UTC\n \n 2019-01-31 20:25: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 349\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.concept_id = 2223 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2019-01-31 20:24:03',4,'2019-01-31 20:25:29',4,0,NULL,NULL,NULL,'f2c9e963-4199-471b-aac4-23627e6d0d71'),(350,'Date enrolled in Pre-ART','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Date enrolled in Pre-ART\n \n \n 2019-01-31 20:39:42 UTC\n \n 2019-01-31 20:40: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 350\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-01-31 20:39:42',4,'2019-01-31 20:40:34',4,0,NULL,NULL,NULL,'5356e185-cedb-417f-a685-7a84a0e828f8'),(351,'HIV Care clients screened for TB SQL','HIV Care clients screened for TB SQL','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HIV Care clients screened for TB SQL\n HIV Care clients screened for TB SQL\n \n 2019-02-03 09:35:06 UTC\n \n 2019-02-03 09:45: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 351\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.concept_id = 3710 \nand o.value_coded in (3709,1876,3639) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2019-02-03 09:35:06',4,'2019-02-03 09:45:13',4,0,NULL,NULL,NULL,'0494f7f1-1aad-4673-b341-507b34e995e0'),(352,'Presumptive tb HIV care SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Presumptive tb HIV care SQL\n \n \n 2019-02-03 09:48:54 UTC\n \n 2019-02-03 09:49: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 352\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.concept_id = 3710 \nand o.value_coded in (1876) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2019-02-03 09:48:54',4,'2019-02-03 09:49:51',4,0,NULL,NULL,NULL,'f494b5e5-474b-4ef7-b987-77e6fbd1d5f9'),(353,'Diagnosed with TB and started treatment SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Diagnosed with TB and started treatment SQL\n \n \n 2019-02-03 09:53:12 UTC\n \n 2019-03-29 06: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 353\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.concept_id in (2237,2358) or (o.concept_id = 3789 and value_coded = 3790)) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2019-02-03 09:53:12',4,'2019-03-29 06:31:40',4,0,NULL,NULL,NULL,'e1467c7d-a287-43ab-ac11-8cc32e4a2723'),(354,'Clients with scheduled appointments SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with scheduled appointments SQL\n \n \n 2019-02-03 11:14:21 UTC\n \n 2019-03-29 07: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 354\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.concept_id = 3751 \nand o.value_coded = 2146 \n\n','2019-02-03 11:14:21',4,'2019-03-29 07:43:21',4,0,NULL,NULL,NULL,'1231a6ce-dd01-49ef-b585-9dbff0c4f663'),(355,'Clients given CTX 2mnths SQL ','CTX > 60','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given CTX 2mnths SQL \n CTX > 60\n \n 2019-02-03 11:39:04 UTC\n \n 2019-02-03 11:46: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 355\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.concept_id = 3728 \nand o.value_numeric > 31 \nand o.value_numeric < 62 \nand MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \nand YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \nand o.voided = 0\n','2019-02-03 11:39:04',4,'2019-02-03 11:46:11',4,0,NULL,NULL,NULL,'23c9999f-939a-477e-8343-782a5e9ba2b2'),(356,'Clients given CTX 3mnths SQL ','CTX <100','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given CTX 3mnths SQL \n CTX <100\n \n 2019-02-03 11:47:00 UTC\n \n 2019-02-04 07:05: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 356\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.concept_id = 3728 \nand o.value_numeric <= 100 \nand MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \nand YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \nand o.voided = 0;\n','2019-02-03 11:47:00',4,'2019-02-04 07:05:42',4,0,NULL,NULL,NULL,'9c8b100f-b3bf-469d-ae65-772cfc53c9ba'),(357,'Clients given curret and multi month CTX','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given curret and multi month CTX\n \n \n 2019-02-03 11:50:40 UTC\n \n 2019-02-03 11:53: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 357\n Clients-given-CTX-2mnths-SQL- OR Clients-given-CTX-3mnths-SQL- OR Clients-given-CTX-SQL\n \n \n Clients-given-CTX-2mnths-SQL-\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 Clients-given-CTX-3mnths-SQL-\n \n \n \n \n \n \n Clients-given-CTX-SQL\n \n \n \n \n \n \n','2019-02-03 11:50:40',4,'2019-02-03 11:53:12',4,0,NULL,NULL,NULL,'4a42a3bb-7340-496f-ab20-a29bb11953a7'),(358,'Newly enrolled in HIV Care,Started IPT SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Newly enrolled in HIV Care,Started IPT SQL\n \n \n 2019-02-03 19:37:54 UTC\n \n 2019-02-03 20:31: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 358\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.concept_id = 2227 \nand o.value_coded = 2146 \nand o.person_id in \n( \nselect person_id \nfrom obs \nwhere concept_id = 2223 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate \n) \nand o.person_id not in \n( \nselect person_id \nfrom obs \nwhere concept_id = 2249 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate \n) \nand o.obs_datetime >=:startDate \nand o.obs_datetime <=:endDate;\n','2019-02-03 19:37:54',4,'2019-02-03 20:31:26',4,0,NULL,NULL,NULL,'2b679b8c-165e-4dbe-8b9d-e7f685a6dae8'),(359,'Clients newly started on ART and IPT','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly started on ART and IPT\n \n \n 2019-02-03 19:59:50 UTC\n \n 2019-02-03 20: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 359\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.concept_id = 2227 \nand o.value_coded = 2146 \nand o.person_id in \n( \nselect person_id \nfrom obs \nwhere concept_id = 2249 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate \n) \nand o.obs_datetime >=:startDate \nand o.obs_datetime <=:endDate;\n','2019-02-03 19:59:50',4,'2019-02-03 20:09:02',4,0,NULL,NULL,NULL,'a10eb64a-10db-4cc9-a69a-e9659e634918'),(360,'pre art test new diagnosed','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n pre art test new diagnosed\n \n \n 2019-02-04 07:51:40 UTC\n \n 2019-02-04 07:56: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 360\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.concept_id = 2222 \nand o.person_id in \n( \nselect person_id \nfrom obs \nwhere concept_id = 2223 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate \n) \nand o.person_id not in \n( \nselect person_id \nfrom obs \nwhere concept_id = 2249 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate \n) \nand o.obs_datetime >=:startDate \nand o.obs_datetime <=:endDate;\n','2019-02-04 07:51:40',4,'2019-02-04 07:56:11',4,0,NULL,NULL,NULL,'44860f5e-0ce8-466d-8c01-c2ff60737256'),(361,'pre art test newly enrolled','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n pre art test newly enrolled\n \n \n 2019-02-04 08:07:56 UTC\n \n 2019-02-04 08:14: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 361\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.concept_id = 2223 \nand o.person_id not in \n( \nselect person_id \nfrom obs \nwhere concept_id = 2249 \n) \nand o.obs_datetime >=:startDate \nand o.obs_datetime <=:endDate;\n','2019-02-04 08:07:56',4,'2019-02-04 08:14:46',4,0,NULL,NULL,NULL,'1796e0e3-bf74-436b-8b98-4258885a7d1f'),(362,'Clients seen in previous 1 through 6 months SQL','All clients seen in previous 1 through 6 months given multi month supply','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen in previous 1 through 6 months SQL\n All clients seen in previous 1 through 6 months given multi month supply\n \n 2019-02-04 13:45:38 UTC\n \n 2024-02-15 09:20: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 362\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 \n(SELECT Id \nFROM ( \n \n (SELECT Id, patientIdentifier , patientName, Age, Gender, age_group, 'Seen_Previous' AS 'Program_Status', sort_order \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.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 and voided = 0 \n and A.observation_id = B.obs_group_id \n and B.voided = 0 \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 and os.voided =0 \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 and os.voided = 0 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n \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)AS Seen_Prev)\n','2019-02-04 19:15:38',4,'2024-02-15 14:50:35',4,0,NULL,NULL,NULL,'6f3593ef-a36c-4d2c-a10b-801b5bc8596b'),(363,'Clients with baseline CD4 counts 12mnths','Clients with baseline CD4 counts 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with baseline CD4 counts 12mnths\n Clients with baseline CD4 counts 12mnths\n \n 2019-02-05 08:52:36 UTC\n \n 2019-02-05 08:53: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 363\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 10:52:36',4,'2019-02-05 10:53:32',4,0,NULL,NULL,NULL,'fa2725bc-529d-43a8-8153-815da5e1cfca'),(364,'Clients with baseline CD4 counts 6mnths','Clients with baseline CD4 counts 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with baseline CD4 counts 6mnths\n Clients with baseline CD4 counts 6mnths\n \n 2019-02-05 08:54:13 UTC\n \n 2019-02-05 08:57: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 364\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 10:54:13',4,'2019-02-05 10:57:42',4,0,NULL,NULL,NULL,'f47faba9-8813-4593-8f6a-a6fe13d0e378'),(365,'Clients still on original firstline 6mnths','Clients still on original firstline 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients still on original firstline 6mnths\n Clients still on original firstline 6mnths\n \n 2019-02-05 08:59:32 UTC\n \n 2019-02-05 09:00: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 365\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 10:59:32',4,'2019-02-05 11:00:54',4,0,NULL,NULL,NULL,'8b0102ef-3c90-49f8-8d7c-f49f3af9d70e'),(366,'Clients still on original firstline 12mnths','Clients still on original firstline 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients still on original firstline 12mnths\n Clients still on original firstline 12mnths\n \n 2019-02-05 09:01:30 UTC\n \n 2019-02-05 09:02: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 366\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:01:30',4,'2019-02-05 11:02:20',4,0,NULL,NULL,NULL,'63f43e63-76e4-4d5a-b680-5e1fb48a419d'),(367,'Clients on alternative 1st line 6mnths','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients on alternative 1st line 6mnths\n \n \n 2019-02-05 09:03:10 UTC\n \n 2019-02-05 09:05: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 367\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:03:10',4,'2019-02-05 11:05:30',4,0,NULL,NULL,NULL,'3512308a-d7a1-4695-bee3-fe760dd7da54'),(368,'Clients on alternative 1st line 12mnths','Clients on alternative 1st line 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients on alternative 1st line 12mnths\n Clients on alternative 1st line 12mnths\n \n 2019-02-05 09:06:09 UTC\n \n 2019-02-05 09:06: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 368\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:06:09',4,'2019-02-05 11:06:51',4,0,NULL,NULL,NULL,'9ffbb2d4-8048-48bd-b851-b82557ca72d6'),(369,'Clients switched to 2nd line 6mnths','Clients switched to 2nd line 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients switched to 2nd line 6mnths\n Clients switched to 2nd line 6mnths\n \n 2019-02-05 09:08:12 UTC\n \n 2019-02-05 09:09: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 369\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:08:12',4,'2019-02-05 11:09:28',4,0,NULL,NULL,NULL,'b4c517ae-ed0c-4bf3-9f3e-8d94304b8659'),(370,'Clients switched to 2nd line 12mnths','Clients switched to 2nd line 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients switched to 2nd line 12mnths\n Clients switched to 2nd line 12mnths\n \n 2019-02-05 09:10:26 UTC\n \n 2019-02-05 09:11: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 370\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:10:26',4,'2019-02-05 11:11:30',4,0,NULL,NULL,NULL,'74e22b7b-d25f-4b23-864e-afd719a2ebc6'),(371,'Clients with follow up CD4 6mnths','Clients with follow up CD4 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with follow up CD4 6mnths\n Clients with follow up CD4 6mnths\n \n 2019-02-05 09:12:07 UTC\n \n 2019-02-05 09: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 371\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:12:07',4,'2019-02-05 11:15:04',4,0,NULL,NULL,NULL,'7b66107d-e6fb-48a3-ad99-d6a81b1269d9'),(372,'Clients with follow up CD4 12mnths','Clients with follow up CD4 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with follow up CD4 12mnths\n Clients with follow up CD4 12mnths\n \n 2019-02-05 09:15:54 UTC\n \n 2019-02-05 09:17: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 372\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:15:54',4,'2019-02-05 11:17:58',4,0,NULL,NULL,NULL,'e1ae9120-353f-4c65-85b9-184be1542760'),(373,'Clients with follow up Viral Load 6mnths','Clients with follow up Viral Load 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with follow up Viral Load 6mnths\n Clients with follow up Viral Load 6mnths\n \n 2019-02-05 09:19:41 UTC\n \n 2019-02-05 09:21: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 373\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:19:41',4,'2019-02-05 11:21:35',4,0,NULL,NULL,NULL,'5aa44431-8661-4c1e-92fe-8c117831f418'),(374,'Clients with follow up Viral Load 12mnths','Clients with follow up Viral Load 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with follow up Viral Load 12mnths\n Clients with follow up Viral Load 12mnths\n \n 2019-02-05 09:22:53 UTC\n \n 2019-02-05 09:25: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 374\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:22:53',4,'2019-02-05 11:25:34',4,0,NULL,NULL,NULL,'eb510470-5a6d-45a4-bdeb-6d905570bd0d'),(375,'Clients lost to follow up 6mnths','Clients lost to follow up 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients lost to follow up 6mnths\n Clients lost to follow up 6mnths\n \n 2019-02-05 09:26:21 UTC\n \n 2019-02-05 09:28: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 375\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:26:21',4,'2019-02-05 11:28:11',4,0,NULL,NULL,NULL,'3efb72d7-384b-4492-8ef5-1e158fecae2a'),(376,'Clients lost to follow up 12mnths','Clients lost to follow up 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients lost to follow up 12mnths\n Clients lost to follow up 12mnths\n \n 2019-02-05 09:28:53 UTC\n \n 2019-02-05 09:31: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 376\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:28:53',4,'2019-02-05 11:31:22',4,0,NULL,NULL,NULL,'3e0765e1-b5cc-43ca-bc89-4585f5e9e7fb'),(377,'Clients dead 6mnths','Clients dead 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients dead 6mnths\n Clients dead 6mnths\n \n 2019-02-05 09:32:07 UTC\n \n 2019-02-05 09:33: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 377\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:32:07',4,'2019-02-05 11:33:08',4,0,NULL,NULL,NULL,'1f29b6b1-21b8-4931-9a38-a1cefbc302d3'),(378,'Clients dead 12 mnths','Clients dead 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients dead 12 mnths\n Clients dead 12mnths\n \n 2019-02-05 09:33:37 UTC\n \n 2019-02-05 09:34: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 378\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:33:37',4,'2019-02-05 11:34:30',4,0,NULL,NULL,NULL,'991435d7-ccd5-4e80-882f-bb8e3bf4f8b8'),(379,'Clients stopped 6mnths','Clients stopped 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients stopped 6mnths\n Clients stopped 6mnths\n \n 2019-02-05 09:35:01 UTC\n \n 2019-02-05 09:36: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 379\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:35:01',4,'2019-02-05 11:36:07',4,0,NULL,NULL,NULL,'c72f56a8-b67f-43ad-a2e4-a10be338e482'),(380,'Clients stopped 12 mnths','Clients stopped 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients stopped 12 mnths\n Clients stopped 12mnths\n \n 2019-02-05 09:36:39 UTC\n \n 2019-02-05 09:37: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 380\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:36:39',4,'2019-02-05 11:37:32',4,0,NULL,NULL,NULL,'8effc480-73a0-4806-9555-44ac56e09d6e'),(382,'Clients newly initiated 1c','1c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1c\n 1c\n \n 2019-02-06 15:02:44 UTC\n \n 2021-01-27 14:36: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 382\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2201 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:02:44',4,'2021-01-27 14:36:25',4,0,NULL,NULL,NULL,'eb143dfc-1a1c-4e1c-b2d9-243ca86dd111'),(383,'Clients newly initiated 1d ','1d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1d \n 1d\n \n 2019-02-06 15:13:24 UTC\n \n 2021-01-27 14:38: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 383\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2203 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:13:24',4,'2021-01-27 14:38:16',4,0,NULL,NULL,NULL,'3d4080ed-278a-4c48-a9a9-4d1c9359b3c5'),(384,'Clients newly initiated 1e','1e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1e\n 1e\n \n 2019-02-06 15:15:37 UTC\n \n 2021-01-27 14:39: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 384\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2205 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:15:37',4,'2021-01-27 14:39:22',4,0,NULL,NULL,NULL,'d1b27fb7-6798-4562-bbe2-7d2d71ccba59'),(385,'Clients newly initiated 1f','1f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1f\n 1f\n \n 2019-02-06 15:16:38 UTC\n \n 2021-01-27 14: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 385\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2207 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:16:38',4,'2021-01-27 14:39:57',4,0,NULL,NULL,NULL,'ce0026fa-a5a0-4729-9442-76d4e651f94a'),(386,'Clients newly initiated 1g ','1g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1g \n 1g\n \n 2019-02-06 15:18:38 UTC\n \n 2021-01-27 14:40: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 386\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3672 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:18:38',4,'2021-01-27 14:40:32',4,0,NULL,NULL,NULL,'05918dc5-51c4-4556-be64-efa548ddc957'),(387,'Clients newly initiated 1h','1h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1h\n 1h\n \n 2019-02-06 15:20:41 UTC\n \n 2021-01-27 14:41: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 387\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3673 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:20:41',4,'2021-01-27 14:41:11',4,0,NULL,NULL,NULL,'5147b850-5fee-42d3-b2bf-0c074c9eca96'),(388,'Clients newly initiated 2c','2c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2c\n 2c\n \n 2019-02-06 15:23:30 UTC\n \n 2021-01-27 14:52: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 388\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2210 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:23:30',4,'2021-01-27 14:52:56',4,0,NULL,NULL,NULL,'14d94e25-3c55-4434-b0ad-64e23f6a5404'),(389,'Clients newly initiated 2d','2d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2d\n 2d\n \n 2019-02-06 15:25:19 UTC\n \n 2021-01-27 14:53: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 389\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2209 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:25:19',4,'2021-01-27 14:53:48',4,0,NULL,NULL,NULL,'03f49548-9c17-4f5f-94d9-4e616d2758b8'),(390,'Clients newly initiated 2e','2e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2e\n 2e\n \n 2019-02-06 15:26:27 UTC\n \n 2021-01-27 14:54: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 390\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3674 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:26:27',4,'2021-01-27 14:54:34',4,0,NULL,NULL,NULL,'db68cb15-10f6-4f65-bee5-3c69d079c441'),(391,'Clients newly initiated 2f ','2f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2f \n 2f\n \n 2019-02-06 15:27:26 UTC\n \n 2021-01-27 14:55: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 391\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3675 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:27:26',4,'2021-01-27 14:55:21',4,0,NULL,NULL,NULL,'d3645a04-6157-4855-b645-d19c73b2827c'),(392,'Clients newly initiated 2g','2g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2g\n 2g\n \n 2019-02-06 15:28:29 UTC\n \n 2021-01-27 14:57: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 392\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3676 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:28:29',4,'2021-01-27 14:57:07',4,0,NULL,NULL,NULL,'0d4335ea-74f0-4cca-8ed7-ca4fa033880e'),(393,'Clients newly initiated 2h','2h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2h\n 2h\n \n 2019-02-06 15:29:20 UTC\n \n 2021-01-27 14:57: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 393\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3677 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:29:20',4,'2021-01-27 14:57:48',4,0,NULL,NULL,NULL,'4d44a02b-fe31-450d-887a-c5e769a13cb1'),(394,'Clients newly initiated 3a','3a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 3a\n 3a\n \n 2019-02-07 08:20:56 UTC\n \n 2021-01-27 15:12: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 394\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3683 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-07 08:20:56',4,'2021-01-27 15:12:32',4,0,NULL,NULL,NULL,'995ebf26-1945-4e6a-b041-c401c06d4b90'),(395,'Clients newly initiated 3b','3b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 3b\n 3b\n \n 2019-02-07 08:21:56 UTC\n \n 2021-01-27 15:14: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 395\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3684 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-07 08:21:56',4,'2021-01-27 15:14:28',4,0,NULL,NULL,NULL,'b447da00-0b30-4205-8027-ebe5951ed320'),(400,'Clients seen 4c','4c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 4c\n 4c\n \n 2019-02-07 10:22:40 UTC\n \n 2019-05-08 09:05: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 400\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2202 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-02-07 10:22:40',4,'2019-05-08 09:05:39',4,0,NULL,NULL,NULL,'568c8c09-01b5-4a1c-8892-f558350b2abf'),(401,'Clients seen 4d','4d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 4d\n 4d\n \n 2019-02-07 10:24:59 UTC\n \n 2019-05-08 09: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 401\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2204 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date < :endDate \n and dead = 1 \n ) \n \n \n','2019-02-07 10:24:59',4,'2019-05-08 09:53:30',4,0,NULL,NULL,NULL,'df3b2c47-8c25-4a90-a9cf-4a98a52d87de'),(402,'Clients seen 4e','4e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 4e\n 4e\n \n 2019-02-07 10:28:19 UTC\n \n 2019-05-08 09:54: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 402\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3679 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-02-07 10:28:19',4,'2019-05-08 09:54:32',4,0,NULL,NULL,NULL,'37ad57a6-6821-4f3b-bc29-05ab90bc774a'),(403,'Clients seen 4f','4f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 4f\n 4f\n \n 2019-02-07 10:29:37 UTC\n \n 2019-05-08 09:55: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 403\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3680 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date < :endDate \n and dead = 1 \n ) \n \n \n','2019-02-07 10:29:37',4,'2019-05-08 09:55:25',4,0,NULL,NULL,NULL,'ad3ba0a3-3589-4b24-8645-ea12a81be5bf'),(404,'Clients seen 6a','6a RAL-EFV-LPV','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 6a\n 6a RAL-EFV-LPV\n \n 2019-02-07 10:39:49 UTC\n \n 2019-05-08 10:48: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 404\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3686 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-02-07 10:39:49',4,'2019-05-08 10:48:52',4,0,NULL,NULL,NULL,'a20a7a05-5360-43b9-b48e-81294d4f06e9'),(406,'Clients newly initiated 3c','3c as 6a under dhis2 adults 3rd line','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 3c\n 3c as 6a under dhis2 adults 3rd line\n \n 2019-02-07 11:02:00 UTC\n \n 2021-01-27 15:20: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 406\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3685 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-07 11:02:00',4,'2021-01-27 15:20:40',4,0,NULL,NULL,NULL,'354eee1a-35a6-473c-9029-4e4e66042646'),(407,'Clients seen 3c','3c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 3c\n 3c\n \n 2019-02-07 13:35:11 UTC\n \n 2019-05-08 10:38: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 407\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-02-07 13:35:11',4,'2019-05-08 10:38:50',4,0,NULL,NULL,NULL,'604a75e1-4aac-413b-be90-3c3f5f0e1506'),(408,'Clients multi month 3c','3c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 3c\n 3c\n \n 2019-02-07 13:57:32 UTC\n \n 2019-05-09 09:40: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 408\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-02-07 13:57:32',4,'2019-05-09 09:40:39',4,0,NULL,NULL,NULL,'30fa519d-6d87-453f-a68f-fbfe97d650b9'),(409,'Clients seen given 1 month supply 4c','4c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4c\n 4c\n \n 2019-02-07 14:01:00 UTC\n \n 2021-02-04 07:31: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 409\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 2202) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 2202 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2019-02-07 14:01:00',4,'2021-02-04 07:31:35',4,0,NULL,NULL,NULL,'537bfeb1-7f85-4387-81c1-79f35d6b8193'),(410,'Clients seen given 1 month supply 4d','4d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4d\n 4d\n \n 2019-02-07 14:02:06 UTC\n \n 2021-02-04 07:32: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 410\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 2204) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 2204 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2019-02-07 14:02:06',4,'2021-02-04 07:32:24',4,0,NULL,NULL,NULL,'306b1f50-9652-42e5-9f9f-bacb1a1f3ed1'),(411,'Clients seen given 1 month supply 4e','4e ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4e\n 4e \n \n 2019-02-07 14:05:31 UTC\n \n 2021-02-04 07: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 411\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3679) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3679 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2019-02-07 14:05:31',4,'2021-02-04 07:35:39',4,0,NULL,NULL,NULL,'7bd605b0-4f07-4730-b79e-ea885c4dc22a'),(412,'Clients seen given 1 month supply 4f','4f ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4f\n 4f \n \n 2019-02-07 14:09:36 UTC\n \n 2021-02-04 07:36: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 412\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3680) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3680 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2019-02-07 14:09:36',4,'2021-02-04 07:36:27',4,0,NULL,NULL,NULL,'61c10574-82e0-409f-b573-2ed12e5234ef'),(413,'Clients seen given 1 month supply 5a','5a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 5a\n 5a\n \n 2019-02-07 14:14:11 UTC\n \n 2021-02-04 07:47: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 413\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3681) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3681 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2019-02-07 14:14:11',4,'2021-02-04 07:47:50',4,0,NULL,NULL,NULL,'35491dfa-1e7f-4a01-9c4c-3d741887d1fc'),(414,'Clients seen given 1 month supply 5b','5b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 5b\n 5b\n \n 2019-02-07 14:16:20 UTC\n \n 2021-02-04 07:55: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 414\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3682) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3682 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2019-02-07 14:16:20',4,'2021-02-04 07:55:49',4,0,NULL,NULL,NULL,'b828f7ad-12f5-42fa-9217-e1deb46fb67b'),(415,'Clients seen 5a','5a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 5a\n 5a\n \n 2019-02-07 14:18:43 UTC\n \n 2019-05-08 10:18: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 415\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3681 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-02-07 14:18:43',4,'2019-05-08 10:18:10',4,0,NULL,NULL,NULL,'79aeb902-4831-4559-9766-1fcfe976732d'),(416,'Clients seen 5b','5b 2 or 3mnths','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 5b\n 5b 2 or 3mnths\n \n 2019-02-07 14:19:37 UTC\n \n 2019-05-08 10: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 416\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3682 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-02-07 14:19:37',4,'2019-05-08 10:21:05',4,0,NULL,NULL,NULL,'08e17546-29ca-41a6-8457-faa0da7126d1'),(417,'CMP_ART Regimen 1month supply 5g','5g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 5g\n 5g\n \n 2019-02-07 14:22:10 UTC\n \n 2021-01-28 00:57: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 417\n Clients-newly-initiated-5g OR Clients-seen-given-1-month-supply-5g\n \n \n Clients-newly-initiated-5g\n \n \n \n \n endDate\n ${}\n \n \n location\n ${}\n \n \n startDate\n ${}\n \n \n \n \n \n Clients-seen-given-1-month-supply-5g\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','2019-02-07 14:22:10',4,'2021-01-28 00:57:28',4,0,NULL,NULL,NULL,'c90d4873-21fb-444f-94f3-0c29f7e1c723'),(418,'CMP_ART Regimen 1month supply 4c','4c ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4c\n 4c \n \n 2019-02-07 14:28:09 UTC\n \n 2021-01-27 23:38: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 418\n Clients-seen-given-1-month-supply-4c OR Clients-newly-initiated-4c\n \n \n Clients-seen-given-1-month-supply-4c\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 Clients-newly-initiated-4c\n \n \n \n \n \n \n','2019-02-07 14:28:09',4,'2021-01-27 23:38:54',4,0,NULL,NULL,NULL,'b734b3a4-c03d-4870-aee6-ae72d7cd09a3'),(419,'CMP_ART Regimen 1month supply 4d','4d ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4d\n 4d \n \n 2019-02-07 14:33:46 UTC\n \n 2021-01-27 23:48: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 419\n Clients-newly-initiated-4d OR Clients-seen-given-1-month-supply-4d\n \n \n Clients-newly-initiated-4d\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 Clients-seen-given-1-month-supply-4d\n \n \n \n \n \n \n','2019-02-07 14:33:46',4,'2021-01-27 23:48:30',4,0,NULL,NULL,NULL,'6fd05fe9-d0f9-4df1-af32-f779445dfa47'),(420,'CMP_ART Regimen 1month supply 4e','4e ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4e\n 4e \n \n 2019-02-07 14:48:47 UTC\n \n 2021-01-27 23:52: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 420\n Clients-newly-initiated-4e OR Clients-seen-given-1-month-supply-4e\n \n \n Clients-newly-initiated-4e\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 Clients-seen-given-1-month-supply-4e\n \n \n \n \n \n \n','2019-02-07 14:48:47',4,'2021-01-27 23:52:23',4,0,NULL,NULL,NULL,'4c813098-94b5-4e1d-8e8a-baeccd78bad2'),(421,'CMP_ART Regimen 1month supply 4f','4f ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4f\n 4f \n \n 2019-02-07 14:53:34 UTC\n \n 2021-01-27 23:55: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 421\n Clients-newly-initiated-4f OR Clients-seen-given-1-month-supply-4f\n \n \n Clients-newly-initiated-4f\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 Clients-seen-given-1-month-supply-4f\n \n \n \n \n \n \n','2019-02-07 14:53:34',4,'2021-01-27 23:55:36',4,0,NULL,NULL,NULL,'33d92626-132a-476e-8c20-0738c0517731'),(424,'CMP_ART Regimen 1month supply 5a','5a ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 5a\n 5a \n \n 2019-02-07 15:09:01 UTC\n \n 2021-01-28 00:23: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 424\n Clients-seen-given-1-month-supply-5a OR Clients-newly-initiated-5a\n \n \n Clients-seen-given-1-month-supply-5a\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 Clients-newly-initiated-5a\n \n \n \n \n \n \n','2019-02-07 15:09:01',4,'2021-01-28 00:23:10',4,0,NULL,NULL,NULL,'e5755cdd-222c-4005-b535-2b7b2027a776'),(425,'Clients given 5a current and multi month','5a 1-3mnths','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5a current and multi month\n 5a 1-3mnths\n \n 2019-02-07 15:16:38 UTC\n \n 2019-02-07 15:17: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 425\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.concept_id = 2250 \nand o.value_coded = 3681 \nand o.voided = 0 \nand obs_datetime between :startDate and :endDate;\n','2019-02-07 15:16:38',4,'2019-02-07 15:17:59',4,0,NULL,NULL,NULL,'f69352a8-954a-409e-9bcc-72c382522568'),(426,'CMP_ART Regimen 1month supply 5b','5b ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 5b\n 5b \n \n 2019-02-07 15:20:08 UTC\n \n 2021-01-28 00:28: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 426\n Clients-seen-given-1-month-supply-5b OR Clients-newly-initiated-5b\n \n \n Clients-seen-given-1-month-supply-5b\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 Clients-newly-initiated-5b\n \n \n \n \n \n \n','2019-02-07 15:20:08',4,'2021-01-28 00:28:10',4,0,NULL,NULL,NULL,'776337cf-5614-4b95-9c43-b322b1a2bd3b'),(427,'CMP_ART Regimen 1month supply 6a','6a ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 6a\n 6a \n \n 2019-02-07 15:24:04 UTC\n \n 2021-01-28 01:16: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 427\n Clients-seen-given-1-month-supply-6a OR Clients-newly-initiated-6a\n \n \n Clients-seen-given-1-month-supply-6a\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 Clients-newly-initiated-6a\n \n \n \n \n \n \n','2019-02-07 15:24:04',4,'2021-01-28 01:16:54',4,0,NULL,NULL,NULL,'dba3de7f-67e9-4b23-b63e-7c58c308165d'),(428,'Clients seen given 1 month supply 6a','6a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 6a\n 6a\n \n 2019-02-07 15:28:03 UTC\n \n 2021-02-04 08:14: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 428\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3686) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3686 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2019-02-07 15:28:03',4,'2021-02-04 08:14:10',4,0,NULL,NULL,NULL,'53316cf7-0a79-49e4-9dd4-5f00f847b3b1'),(429,'TESTING','ALL TESTS','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TESTING\n ALL TESTS\n \n 2019-02-12 09:23:54 UTC\n \n 2019-02-19 10:51: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 429\n select distinct person_id \nfrom obs \nwhere concept_id = 3843 \nand value_coded in (3841) \nAND (DATE(obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1)); \n \n\n','2019-02-12 09:23:54',4,'2019-02-19 10:51:01',4,0,NULL,NULL,NULL,'0e162295-6055-46ea-8c17-5fca300d0054'),(430,'testing','n/a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n testing\n n/a\n \n 2019-02-13 14:14:05 UTC\n \n 2020-07-06 07:28: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 430\n (select o.person_id,CAST(value_datetime AS DATE) as blood_drawn \nfrom obs o \ninner join \n (select person_id,max(obs_datetime) maxdate \n from obs a \n where obs_datetime <= :endDate \n and concept_id = 4267 \n group by person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 4267 \n and o.obs_datetime = maxdate \n )\n','2019-02-13 14:14:05',4,'2020-07-06 07:28:05',4,0,NULL,NULL,NULL,'dd019ae7-3549-4fd7-b3ee-b7ac841707f2'),(431,'lets see','N/A','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n lets see\n N/A\n \n 2019-02-15 10:05:49 UTC\n \n 2019-02-15 12:46: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 431\n SELECT DISTINCT Id \nFROM \n \n( \nselect distinct patient.patient_id AS Id \n \n from obs o \n \n \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD('2019-01-31', INTERVAL -1 MONTH)) \n and YEAR(o.obs_datetime) = YEAR(DATE_ADD('2019-01-31', INTERVAL -1 MONTH)) \n AND patient.voided = 0 \n AND o.voided = 0 \n AND (o.concept_id = 4174 and (o.value_coded in (4176,4177,4245,4246,4247))) \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 \n AND patient_identifier.identifier_type = 3 \n \n \n \nUNION \n \nselect distinct patient.patient_id AS Id \n \n from obs o \n \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD('2019-01-31', INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD('2019-01-31', INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4175 \n AND o.person_id in ( \n select distinct os.person_id from obs os \n \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD('2019-01-31', INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD('2019-01-31', INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 \n AND DATEDIFF(os.value_datetime, '2019-01-31') BETWEEN 0 AND 28 \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 \n \n \n \n) AS ARTCurrent_PrevMonths \n \nWHERE Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n \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 (DATE(o.obs_datetime) BETWEEN '2019-01-01' AND addDate('2019-01-31', 1)) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id \n AND patient_identifier.identifier_type = 3 \nWHERE patient.patient_id not in ( \n select distinct patient.patient_id AS Id \n from obs o \n -- CLIENTS NEWLY INITIATED ON ART \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN '2019-01-01' AND addDate('2019-01-31', 1)) \nAND patient.voided = 0 AND o.voided = 0 \n \nAND 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 DATE(os.obs_datetime) BETWEEN '2019-01-01' AND addDate('2019-01-31', 1) \n \n ) \n ))\n','2019-02-15 10:05:49',4,'2019-02-15 12:46:15',4,0,NULL,NULL,NULL,'82d59123-ac4a-4c14-8218-0738d4ade605'),(432,'Clients given 4mnths 1f in previous 3mnths','1f 4mnths ago','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4mnths 1f in previous 3mnths\n 1f 4mnths ago\n \n 2019-02-19 09:39:58 UTC\n \n 2019-02-19 09:58: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 432\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.concept_id = 4174 and o.value_coded in (4245,4246) \n \nand o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 2250 \n and os.value_coded = 2207 \n and MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n and YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n) \n \nand MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \nand YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \nand o.voided = 0\n','2019-02-19 09:39:58',4,'2019-02-19 09:58:09',4,0,NULL,NULL,NULL,'c2adcb8a-c735-4860-a9d8-9509ac29d363'),(433,'Clients given 5mnths 1f in previous m4nths','1f 5mnths ago','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5mnths 1f in previous m4nths\n 1f 5mnths ago\n \n 2019-02-19 09:59:13 UTC\n \n 2019-02-19 10:02: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 433\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.concept_id = 4174 and o.value_coded in (4246) \n \nand o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 2250 \n and os.value_coded = 2207 \n and MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n and YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n) \n \nand MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \nand YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \nand o.voided = 0\n','2019-02-19 09:59:13',4,'2019-02-19 10:02:40',4,0,NULL,NULL,NULL,'809ab22c-a795-46ba-b8af-1a21a51551e4'),(435,'Master HIVTC 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 Master HIVTC report Data Set\n \n 2019-02-21 14:56:31 UTC\n \n 2019-03-01 10:34: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 435\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n \n \n DM_Weight_Updated\n \n \n \n \n \n \n \n \n 1ST4c3.9F\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 Children 0to14\n \n \n DM_Weight_Updated\n 03to3.9kg\n \n \n \n \n \n 1st4c3.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 03to3.9kg\n \n \n \n \n \n 1st4c5.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 04to5.9kg\n \n \n \n \n \n 1st4c5.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 04to5.9kg\n \n \n \n \n \n 1st4d13.9F\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 10to13.9kg\n \n \n \n \n \n 1st4d13.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 10to13.9kg\n \n \n \n \n \n 1st4d19.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 14to19.9kg\n \n \n \n \n \n 1st4d19.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 14to19.9kg\n \n \n \n \n \n 1st4d24.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 20to24.9kg\n \n \n \n \n \n 1st4d24.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 20to24.9kg\n \n \n \n \n \n 1st4d25F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 25+kg\n \n \n \n \n \n 1st4d25M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 25+kg\n \n \n \n \n \n 1st4d3.9F\n \n \n \n \n \n \n 1st4d3.9M\n \n \n \n \n \n \n 1st4d5.9F\n \n \n \n \n \n \n 1st4d5.9M\n \n \n \n \n \n \n 1st4d9.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 06to9.9kg\n \n \n \n \n \n 1st4d9.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 06to9.9kg\n \n \n \n \n \n 1stlineCF\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Adults\n \n \n \n \n \n 1stlineCM\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Adults\n \n \n \n \n \n 1stlineDF\n \n \n \n \n \n \n \n \n \n 1stlineDM\n \n \n \n \n \n \n 1stlineEF\n \n \n \n \n \n \n \n \n \n 1stlineEM\n \n \n \n \n \n \n 1stlineFF\n \n \n \n \n \n \n \n \n \n 1stlineFM\n \n \n \n \n \n \n 1stlineGF\n \n \n \n \n \n \n \n \n \n 1stlineGM\n \n \n \n \n \n \n 1stlineHF\n \n \n \n \n \n \n \n \n \n 1stlineHM\n \n \n \n \n \n \n','2019-02-21 14:56:31',4,'2019-03-01 10:34:21',4,0,NULL,NULL,NULL,'41857c4c-d7eb-4ab2-8266-3bb1cdb084f0'),(436,'clients seen 2months ago','2mnths+','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients seen 2months ago\n 2mnths+\n \n 2019-02-27 10:29:03 UTC\n \n 2019-02-27 10:29: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 436\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n and YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and (o.value_coded = 4176 or o.value_coded = 4177 or o.value_coded = 4245 or o.value_coded = 4246 or o.value_coded = 4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id \n AND patient_identifier.identifier_type = 3 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4175 \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4176 \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \n \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id \n AND patient_identifier.identifier_type = 3 \nand patient.patient_id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 DATE(os.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1) \n \n ) \n ) \n WHERE (o.location_id =:location or parent_location =:location) \n)\n','2019-02-27 10:29:03',4,'2019-02-27 10:29:19',4,0,NULL,NULL,NULL,'a5bf5837-dafc-404e-9eb8-77501187ac6f'),(437,'clients seen 3months ago','3mnths+','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients seen 3months ago\n 3mnths+\n \n 2019-02-27 10:30:44 UTC\n \n 2019-02-27 10:34: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 437\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 \n AND o.voided = 0 \n AND o.concept_id = 4174 \n and (o.value_coded = 4177 or o.value_coded = 4245 or o.value_coded = 4246 or o.value_coded = 4247) \n INNER JOIN person ON person.person_id = patient.patient_id \n 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 \n AND patient_identifier.identifier_type = 3 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4177 \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id \n AND patient_identifier.identifier_type = 3 \nand patient.patient_id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 DATE(os.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1) \n \n ) \n ) \n WHERE (o.location_id =:location or parent_location =:location) \n)\n','2019-02-27 10:30:44',4,'2019-02-27 10:34:49',4,0,NULL,NULL,NULL,'21c776ca-7cbc-4388-a623-06e351469a20'),(438,'clients seen 4months ago','4mnths+','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients seen 4months ago\n 4mnths+\n \n 2019-02-27 10:37:22 UTC\n \n 2019-02-27 10:37: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 438\n SELECT DISTINCT Id \nFROM \n( \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and (o.value_coded = 4245 or o.value_coded = 4246 or o.value_coded = 4247) \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 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4245 \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id \n AND patient_identifier.identifier_type = 3 \nand patient.patient_id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 DATE(os.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1) \n \n ) \n ) \n WHERE (o.location_id =:location or parent_location =:location) \n)\n','2019-02-27 10:37:22',4,'2019-02-27 10:37:36',4,0,NULL,NULL,NULL,'41a0d5e0-f46f-4cd7-a361-ea6ea3b5933e'),(439,'clients seen 5mnths ago','5mnths +','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients seen 5mnths ago\n 5mnths +\n \n 2019-02-27 10:45:50 UTC\n \n 2019-02-27 10:47: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 439\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and (o.value_coded = 4246 or o.value_coded = 4247) \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 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4246 \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 \n WHERE (o.location_id =:location or parent_location =:location) \n \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id \n AND patient_identifier.identifier_type = 3 \nand patient.patient_id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 DATE(os.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1) \n \n ) \n ) \n WHERE (o.location_id =:location or parent_location =:location) \n)\n','2019-02-27 10:45:50',4,'2019-02-27 10:47:06',4,0,NULL,NULL,NULL,'7cef2932-533c-42ca-96fa-90f10ea3badb'),(440,'clients seen 6months ago','6mnths +','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients seen 6months ago\n 6mnths +\n \n 2019-02-27 10:49:11 UTC\n \n 2019-02-27 10:50: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 440\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \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 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location)) \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 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id \n AND patient_identifier.identifier_type = 3 \nand patient.patient_id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 DATE(os.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1) \n \n ) \n ) \n WHERE (o.location_id =:location or parent_location =:location) \n)\n','2019-02-27 10:49:11',4,'2019-02-27 10:50:14',4,0,NULL,NULL,NULL,'5f4b2a04-8b0c-4add-b7c9-7b70515f603d'),(441,'clients seen 2 to 6mnths ago','composition','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients seen 2 to 6mnths ago\n composition\n \n 2019-02-27 10:59:28 UTC\n \n 2019-02-27 14:18: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 441\n clients-seen-3months-ago OR clients-seen-2months-ago\n \n \n clients-seen-3months-ago\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','2019-02-27 10:59:28',4,'2019-02-27 14:18:26',4,0,NULL,NULL,NULL,'8f521b14-95ad-4e4c-b03d-10c0b7b3a0aa'),(442,'Clients on ARV who died','Clients on ARV who died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients on ARV who died\n Clients on ARV who died\n \n 2019-03-29 06:48:55 UTC\n \n 2022-04-28 08:21: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 442\n select person_id \n from person \n where death_date <= CAST(:endDate AS DATE) \n AND MONTH(death_date) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(death_date) = YEAR(CAST(:endDate AS DATE)) \n and dead = 1\n','2019-03-29 06:48:55',4,'2022-04-28 08:21:40',4,0,NULL,NULL,NULL,'914d4f42-66e2-4fce-b1da-d3fce7f95f15'),(443,'Clients given 2weeks ARV','Clients given 2weeks ARV','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 2weeks ARV\n Clients given 2weeks ARV\n \n 2019-03-29 07:53:59 UTC\n \n 2019-03-29 07: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 443\n select distinct Id from( \nselect distinct Id from \n( \n (select distinct o.person_id AS 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 = 2250 \n and o.value_coded in (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n and o.person_id in ( \n select distinct o.person_id \n from obs o \n where (o.concept_id = 4174 and o.value_coded = 4243) \n and obs_datetime BETWEEN :startDate and DATE_ADD(:endDate, INTERVAL 1 DAY) \n ) \n \n and o.voided = 0 \n and obs_datetime BETWEEN :startDate and DATE_ADD(:endDate, INTERVAL 1 DAY) \n ) \n UNION \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -28 DAY)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -28 DAY)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded = 4243) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -28 DAY)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -28 DAY)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id = :location or parent_location = :location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select distinct person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded in (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n ) \n) as regimen \nwhere Id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < DATE_ADD(:endDate, INTERVAL 1 DAY)) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate, INTERVAL 1 DAY) \n and dead = 1 \n ) \n )as final\n','2019-03-29 07:53:59',4,'2019-03-29 07:57:45',4,0,NULL,NULL,NULL,'d8bb0175-47c0-461b-b457-498c8ef3cf27'),(445,'Total 1F Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Total 1F Data Set\n \n 2019-04-24 08:11:13 UTC\n \n 2019-04-24 08:14: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 445\n \n \n DM_Sex\n \n \n \n \n \n \n \n \n 1Line1fF\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 1stLine1FM\n \n \n \n \n DM_Sex\n Males\n \n \n \n \n \n','2019-04-24 08:11:13',4,'2019-04-24 08:14:21',4,0,NULL,NULL,NULL,'9169293f-f54e-4905-a477-15f43395d28a'),(446,'SQL Version Total Clients Registered for ART','SQL Version Total Clients Registered for ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n SQL Version Total Clients Registered for ART\n SQL Version Total Clients Registered for ART\n \n 2019-07-10 12:51:51 UTC\n \n 2023-10-17 14:02:12 UTC\n \n \n location\n \n org.openmrs.Location\n true\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 446\n SELECT distinct p.person_id AS Id \n FROM person p \n INNER JOIN obs o ON o.person_id = p.person_id \n AND o.voided = 0 \n AND o.person_id in \n (select person_id from obs where concept_id = 2403 and voided = 0) \n AND o.person_id not in \n (select person_id from obs where concept_id = 5416 and value_coded = 1 and voided = 0) \n INNER JOIN person_name pn ON p.person_id = pn.person_id \n INNER JOIN patient_identifier pi1 ON pi1.patient_id = p.person_id AND pi1.voided = 0 and pi1.preferred = 1 \n AND pi1.identifier_type = 3 \n LEFT JOIN patient_identifier pi2 ON pi2.patient_id = p.person_id AND pi2.identifier_type in (5,12) \n JOIN location l on o.location_id = l.location_id and l.retired=0 \n WHERE p.voided = 0 \n \nUNION \n \n SELECT distinct o.person_id AS Id \n FROM obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN patient_identifier p ON o.person_id = p.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 \n JOIN location l on o.location_id = l.location_id and l.retired=0 \n WHERE p.identifier_type in (5,12) \n AND o.voided = 0 \n AND o.person_id not in (select person_id from obs where concept_id = 2403 and voided = 0) \n group by patient_identifier.identifier\n','2019-07-10 18:21:51',4,'2023-10-17 19:32:12',4,0,NULL,NULL,NULL,'dabb33fe-f6f9-479c-82a0-d93c5a681b36'),(447,'SQL Version Total Registered ART Client with Intakes captured','SQL Version Total Registered ART Client with Intakes captured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n SQL Version Total Registered ART Client with Intakes captured\n SQL Version Total Registered ART Client with Intakes captured\n \n 2019-07-11 01:08:18 UTC\n \n 2023-10-17 14: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 447\n SELECT distinct p.person_id AS Id \n FROM person p \n INNER JOIN obs o ON o.person_id = p.person_id \n AND o.voided = 0 \n AND o.person_id in \n (select person_id from obs where concept_id = 2249 and voided = 0) \n AND o.person_id not in \n (select person_id from obs where concept_id = 5416 and value_coded = 1 and voided = 0) \n INNER JOIN person_name pn ON p.person_id = pn.person_id \n INNER JOIN patient_identifier pi1 ON pi1.patient_id = p.person_id AND pi1.voided = 0 and pi1.preferred = 1 \n AND pi1.identifier_type = 3 \n LEFT JOIN patient_identifier pi2 ON pi2.patient_id = p.person_id AND pi2.identifier_type in (5,12) \n JOIN location l on o.location_id = l.location_id and l.retired=0 \n WHERE p.voided = 0 \n AND concept_id = 2403 \n \nUNION \n \n SELECT distinct o.person_id AS Id \n FROM obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN patient_identifier p ON o.person_id = p.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 \n JOIN location l on o.location_id = l.location_id and l.retired=0 \n WHERE p.identifier_type in (5,12) \n AND o.voided = 0 \n AND o.person_id not in (select person_id from obs where concept_id = 2403 and voided = 0) \n AND concept_id = 2249 \n group by patient_identifier.identifier\n','2019-07-11 06:38:18',4,'2023-10-17 19:51:57',4,0,NULL,NULL,NULL,'f7926250-cdd1-4446-9106-bfe81ce908f5'),(448,'CI36: Total Registered ART Clients','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI36: Total Registered ART Clients\n \n \n 2019-07-11 01:17:50 UTC\n \n 2019-07-11 01:21: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 448\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-07-11 03:17:50',4,'2019-07-11 03:21:53',4,0,NULL,NULL,NULL,'860c7123-a8a4-46d1-8c5e-2c33ac1a2632'),(449,'CI37: Total Registered ART Clients with Intakes Captured','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI37: Total Registered ART Clients with Intakes Captured\n \n \n 2019-07-11 01:19:42 UTC\n \n 2019-07-11 01:22: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 449\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-07-11 03:19:42',4,'2019-07-11 03:22:26',4,0,NULL,NULL,NULL,'817d04b5-b407-4ede-a59a-8eac041616cd'),(450,'PIR13: Registered ART Clients with Intakes Progress Report','Period Indicator report for all ART client registered who have their intake form captured in eRegister','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR13: Registered ART Clients with Intakes Progress Report\n Period Indicator report for all ART client registered who have their intake form captured in eRegister\n \n 2019-07-11 01:24:13 UTC\n \n 2019-07-11 02: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 450\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','2019-07-11 03:24:13',4,'2019-07-11 04:03:08',4,0,NULL,NULL,NULL,'987a79c2-7ba9-47ff-8623-984851a6ae0e'),(451,'Total Registered ART Clients with Intakes Progress 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 Total Registered ART Clients with Intakes Progress Report Data Set\n \n 2019-07-11 01:24:17 UTC\n \n 2019-07-11 01: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 451\n \n \n \n IntakesReg\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 Registered\n \n \n \n \n \n \n \n \n \n','2019-07-11 03:24:17',4,'2019-07-11 03:26:20',4,0,NULL,NULL,NULL,'78f64364-5e5a-4ddd-aba9-b27bda9fe14d'),(452,'SQL Version Total ART Clients with Registered Visits','SQL Version Total ART Clients with Registered Visits','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n SQL Version Total ART Clients with Registered Visits\n SQL Version Total ART Clients with Registered Visits\n \n 2019-07-14 09:03:29 UTC\n \n 2019-07-14 09:37: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 452\n SELECT DISTINCT p.person_id \nFROM visit v \n JOIN person p on p.person_id = v.patient_id \n JOIN patient_identifier pi on v.patient_id = pi.patient_id and pi.identifier_type=5 \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type = 2 \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 and (l.location_id=:location or l.parent_location =:location) \nWHERE en.encounter_datetime >= :startDate and en.encounter_datetime <= :endDate \n \n\n','2019-07-14 11:03:29',4,'2019-07-14 11:37:46',4,0,NULL,NULL,NULL,'0181b364-876e-4307-bd8c-e986ea00f614'),(453,'SQL Version Clients with Visits with Consultations','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n SQL Version Clients with Visits with Consultations\n \n \n 2019-07-14 09:14:07 UTC\n \n 2019-07-14 09:18: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 453\n SELECT DISTINCT p.person_id as id \nFROM visit v \n JOIN person p on p.person_id = v.patient_id \n JOIN patient_identifier pi on v.patient_id = pi.patient_id and pi.identifier_type=5 \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type = 1 \n JOIN obs o on o.encounter_id=en.encounter_id and o.concept_id=3843 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n and (l.location_id=:location or l.parent_location =:location) \nWHERE en.encounter_datetime >= :startDate and en.encounter_datetime <= :endDate \n \n\n','2019-07-14 11:14:07',4,'2019-07-14 11:18:02',4,0,NULL,NULL,NULL,'08bfa6d5-d894-4fc1-8bb2-2db094829434'),(454,'CI38: Total ART Clients with Visits','Total ART Clients with Visits','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI38: Total ART Clients with Visits\n Total ART Clients with Visits\n \n 2019-07-14 09:25:12 UTC\n \n 2019-07-14 09:25: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 454\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-07-14 11:25:12',4,'2019-07-14 11:25:52',4,0,NULL,NULL,NULL,'9250be3a-1ae9-421e-9504-2bd10456a657'),(455,'CI39: Visiting ART Clients with Consultations','Visiting ART Clients with Consultations','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI39: Visiting ART Clients with Consultations\n Visiting ART Clients with Consultations\n \n 2019-07-14 09:26:59 UTC\n \n 2019-07-14 09:27: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 455\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-07-14 11:26:59',4,'2019-07-14 11:27:44',4,0,NULL,NULL,NULL,'4eccec5c-c7a8-436e-acec-88ed04f477cc'),(456,'PIR14: Total ART Clients with Consultations Process Report','Total ART Clients with Consultations Process Report','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR14: Total ART Clients with Consultations Process Report\n Total ART Clients with Consultations Process Report\n \n 2019-07-14 09:29:43 UTC\n \n 2019-07-14 09:29: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 456\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','2019-07-14 11:29:43',4,'2019-07-14 11:29:46',4,0,NULL,NULL,NULL,'d45c4571-c987-4271-8012-ad3e6e693d3d'),(457,'PIR14: Total ART Clients with Consultations Process 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 PIR14: Total ART Clients with Consultations Process Report Data Set\n \n 2019-07-14 09:29:46 UTC\n \n 2021-12-16 12:12: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 457\n \n \n \n ARTConsult\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 ARTVisits\n \n \n \n \n \n \n \n \n \n Pending1mn\n \n \n \n \n \n \n \n \n \n Pending2mn\n \n \n \n \n \n \n \n \n \n Pending3mn\n \n \n \n \n \n \n \n \n \n TPTComplet\n \n \n \n \n \n \n \n \n \n TPTContinu\n \n \n \n \n \n \n \n \n \n TPTStarted\n \n \n \n \n \n \n \n \n \n VLDraws3mn\n \n \n \n \n \n \n \n \n \n VLResul3mn\n \n \n \n \n \n \n \n \n \n VLResults\n \n \n \n \n \n \n \n \n \n','2019-07-14 11:29:46',4,'2021-12-16 14:12:13',4,0,NULL,NULL,NULL,'80c015cc-fa7f-4423-ad3f-07e7838ed1cb'),(458,'PITC','PITC section of HTS form','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC\n PITC section of HTS form\n \n 2020-04-24 12:00:15 UTC\n \n 2020-04-24 12:00: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 458\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','2020-04-24 12:00:15',4,'2020-04-24 12:00:18',4,0,NULL,NULL,NULL,'6bca981c-5d78-4a63-84e4-9185ea3356e9'),(459,'PITC Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC Data Set\n \n 2020-04-24 12:00:18 UTC\n \n 2020-05-11 07:42: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 459\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 PInewNe14F\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 10to14yrs\n \n \n \n \n \n PInewNe14M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n PInewNe19F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n PInewNe19M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n PInewNe24F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n PInewNe24M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n PInewNe29F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 25to29yrs\n \n \n \n \n \n PInewNe29M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 25to29yrs\n \n \n \n \n \n PInewNe34F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 30to34yrs\n \n \n \n \n \n PInewNe34M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 30to34yrs\n \n \n \n \n \n PInewNe39F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 35to39yrs\n \n \n \n \n \n PInewNe39M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 35to39yrs\n \n \n \n \n \n PInewNe44F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 40to44yrs\n \n \n \n \n \n PInewNe44M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 40to44yrs\n \n \n \n \n \n PInewNe49F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 45to49yrs\n \n \n \n \n \n PInewNe49M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 45to49yrs\n \n \n \n \n \n PInewNe50F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 50to100yrs\n \n \n \n \n \n PInewNe50M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 50to100yrs\n \n \n \n \n \n PInewNeg1F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n PInewNeg1M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n PInewNeg4F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n PInewNeg4M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n PInewNeg9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n PInewNeg9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n PInewPo14F\n \n \n \n \n \n \n \n \n \n PInewPo14M\n \n \n \n \n \n \n PInewPo19F\n \n \n \n \n \n \n PInewPo19M\n \n \n \n \n \n \n PInewPo24F\n \n \n \n \n \n \n PInewPo24M\n \n \n \n \n \n \n PInewPo29F\n \n \n \n \n \n \n PInewPo29M\n \n \n \n \n \n \n PInewPo34F\n \n \n \n \n \n \n PInewPo34M\n \n \n \n \n \n \n PInewPo39F\n \n \n \n \n \n \n PInewPo39M\n \n \n \n \n \n \n PInewPo44F\n \n \n \n \n \n \n PInewPo44M\n \n \n \n \n \n \n PInewPo49F\n \n \n \n \n \n \n PInewPo49M\n \n \n \n \n \n \n PInewPo50F\n \n \n \n \n \n \n PInewPo50M\n \n \n \n \n \n \n PInewPos1F\n \n \n \n \n \n \n PInewPos1M\n \n \n \n \n \n \n PInewPos4F\n \n \n \n \n \n \n PInewPos4M\n \n \n \n \n \n \n PInewPos9F\n \n \n \n \n \n \n PInewPos9M\n \n \n \n \n \n \n PIrepNe14F\n \n \n \n \n \n \n \n \n \n PIrepNe14M\n \n \n \n \n \n \n PIrepNe19F\n \n \n \n \n \n \n PIrepNe19M\n \n \n \n \n \n \n PIrepNe24F\n \n \n \n \n \n \n PIrepNe24M\n \n \n \n \n \n \n PIrepNe29F\n \n \n \n \n \n \n PIrepNe29M\n \n \n \n \n \n \n PIrepNe34F\n \n \n \n \n \n \n PIrepNe34M\n \n \n \n \n \n \n PIrepNe39F\n \n \n \n \n \n \n PIrepNe39M\n \n \n \n \n \n \n PIrepNe44F\n \n \n \n \n \n \n PIrepNe44M\n \n \n \n \n \n \n PIrepNe49F\n \n \n \n \n \n \n PIrepNe49M\n \n \n \n \n \n \n PIrepNe50F\n \n \n \n \n \n \n PIrepNe50M\n \n \n \n \n \n \n PIrepNeg1F\n \n \n \n \n \n \n PIrepNeg1M\n \n \n \n \n \n \n PIrepNeg4F\n \n \n \n \n \n \n PIrepNeg4M\n \n \n \n \n \n \n PIrepNeg9F\n \n \n \n \n \n \n PIrepNeg9M\n \n \n \n \n \n \n PIrepPo14F\n \n \n \n \n \n \n \n \n \n PIrepPo14M\n \n \n \n \n \n \n PIrepPo19F\n \n \n \n \n \n \n PIrepPo19M\n \n \n \n \n \n \n PIrepPo24F\n \n \n \n \n \n \n PIrepPo24M\n \n \n \n \n \n \n PIrepPo29F\n \n \n \n \n \n \n PIrepPo29M\n \n \n \n \n \n \n PIrepPo34F\n \n \n \n \n \n \n PIrepPo34M\n \n \n \n \n \n \n PIrepPo39F\n \n \n \n \n \n \n PIrepPo39M\n \n \n \n \n \n \n PIrepPo44F\n \n \n \n \n \n \n PIrepPo44M\n \n \n \n \n \n \n PIrepPo49F\n \n \n \n \n \n \n PIrepPo49M\n \n \n \n \n \n \n PIrepPo50F\n \n \n \n \n \n \n PIrepPo50M\n \n \n \n \n \n \n PIrepPos1F\n \n \n \n \n \n \n PIrepPos1M\n \n \n \n \n \n \n PIrepPos4F\n \n \n \n \n \n \n PIrepPos4M\n \n \n \n \n \n \n PIrepPos9F\n \n \n \n \n \n \n PIrepPos9M\n \n \n \n \n \n \n','2020-04-24 12:00:18',4,'2020-05-11 07:42:03',4,0,NULL,NULL,NULL,'d6f4d251-130b-4380-aba8-ddfeae303d42'),(460,'PITC_New_Negative','PITC_New_Negative clients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative\n PITC_New_Negative clients\n \n 2020-04-24 12:18:19 UTC\n \n 2021-07-22 18:12: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 460\n select distinct patient.patient_id AS Id \n \nfrom obs o \n-- HTS CLIENTS WITH NEGATIVE HIV STATUS BY SEX AND AGE \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND o.concept_id = 2165 and o.value_coded = 1016 \nAND patient.voided = 0 AND o.voided = 0 \nAND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n-- PROVIDER INITIATED TESTING AND COUNSELING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 4228 and os.value_coded = 4227 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \n-- NEW TESTER, DOES NOT HAVE A HISTORY OF PREVIOUS TESTING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 2137 and os.value_coded = 2147 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \nINNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n-- Observations inside the HIV Testing and Couseling Form \nAND o.obs_group_id in ( \nselect og.obs_id from obs og where og.concept_id = 2385 \n) \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location)\n','2020-04-24 17:48:19',4,'2021-07-22 23:42:46',4,0,NULL,NULL,NULL,'e9556cb4-8e7f-4de4-9384-0b1ebacad149'),(461,'PITC_New_Positive','new tested positive clients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive\n new tested positive clients\n \n 2020-04-24 12:22:19 UTC\n \n 2021-07-22 18:14: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 461\n select distinct patient.patient_id AS Id \n \nfrom obs o \n-- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND o.concept_id = 2165 and o.value_coded = 1738 \nAND patient.voided = 0 AND o.voided = 0 \nAND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n-- PROVIDER INITIATED TESTING AND COUNSELING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 4228 and os.value_coded = 4227 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \n-- NEW TESTER, DOES NOT HAVE A HISTORY OF PREVIOUS TESTING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 2137 and os.value_coded = 2147 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \nINNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n-- Observations inside the HIV Testing and Couseling Form \nAND o.obs_group_id in ( \nselect og.obs_id from obs og where og.concept_id = 2385 \n) \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location)\n','2020-04-24 17:52:19',4,'2021-07-22 23:44:17',4,0,NULL,NULL,NULL,'1a4da7db-09d2-4d28-b38d-bed4cf703253'),(462,'PITC_Repeat_Negative','PITC repeat negative clients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative\n PITC repeat negative clients\n \n 2020-04-24 12:28:12 UTC\n \n 2021-07-22 18:15: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 462\n select distinct patient.patient_id AS Id \n \nfrom obs o \n-- HTS CLIENTS WITH NEGATIVE HIV STATUS BY SEX AND AGE \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND o.concept_id = 2165 and o.value_coded = 1016 \nAND patient.voided = 0 AND o.voided = 0 \nAND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n-- PROVIDER INITIATED TESTING AND COUNSELING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 4228 and os.value_coded = 4227 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \n-- REPEAT TESTER, AVE A HISTORY OF PREVIOUS TESTING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 2137 and os.value_coded = 2146 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \nINNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n-- Observations inside the HIV Testing and Couseling Form \nAND o.obs_group_id in ( \nselect og.obs_id from obs og where og.concept_id = 2385 \n) \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location)\n','2020-04-24 17:58:12',4,'2021-07-22 23:45:21',4,0,NULL,NULL,NULL,'0750dd97-8565-4679-a1c2-052dc049f345'),(463,'PITC_Repeat_Positive','repeat positive clients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive\n repeat positive clients\n \n 2020-04-24 12:31:42 UTC\n \n 2021-07-22 18: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 463\n select distinct patient.patient_id AS Id \n \nfrom obs o \n-- HTS CLIENTS WITH POSITIVE HIV STATUS BY SEX AND AGE \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND o.concept_id = 2165 and o.value_coded = 1738 \nAND patient.voided = 0 AND o.voided = 0 \nAND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n-- PROVIDER INITIATED TESTING AND COUNSELING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 4228 and os.value_coded = 4227 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \n-- REPEAT TESTER, AVE A HISTORY OF PREVIOUS TESTING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 2137 and os.value_coded = 2146 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \nINNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n-- Observations inside the HIV Testing and Couseling Form \nAND o.obs_group_id in ( \nselect og.obs_id from obs og where og.concept_id = 2385 \n) \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location)\n','2020-04-24 18:01:42',4,'2021-07-22 23:46:15',4,0,NULL,NULL,NULL,'9bba9c3a-f886-477f-997f-a7325a668ee7'),(464,'PITC New Negative','PITC New Negative','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC New Negative\n PITC New Negative\n \n 2020-04-24 12:38:16 UTC\n \n 2020-04-24 12:39: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 464\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-04-24 12:38:16',4,'2020-04-24 12:39:14',4,0,NULL,NULL,NULL,'e4a53f3d-9351-4ba9-a039-c1f772b53b05'),(465,'PITC_New_Positive','new positives','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive\n new positives\n \n 2020-04-24 12:45:45 UTC\n \n 2020-04-24 12: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 465\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-04-24 12:45:45',4,'2020-04-24 12:46:35',4,0,NULL,NULL,NULL,'5038a34b-49da-411b-8bb9-bf7ea784fb7e'),(466,'PITC repeat negative','repeat clients who tested negative','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC repeat negative\n repeat clients who tested negative\n \n 2020-04-24 12:48:17 UTC\n \n 2020-04-24 12:49: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 466\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-04-24 12:48:17',4,'2020-04-24 12:49:08',4,0,NULL,NULL,NULL,'e951ced0-d54a-4614-ba74-27a78e8e18df'),(467,'PITC repeat positive','repeating clients who tested positive','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC repeat positive\n repeating clients who tested positive\n \n 2020-04-24 12:50:04 UTC\n \n 2020-04-24 12:50: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 467\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-04-24 12:50:04',4,'2020-04-24 12:50:52',4,0,NULL,NULL,NULL,'e359947f-9dd8-490f-a1c2-056afb801816'),(468,'CITC_Repeat_Positive','repeat clients tested positve','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive\n repeat clients tested positve\n \n 2020-04-27 05:28:31 UTC\n \n 2021-07-22 18:11: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 468\n select distinct patient.patient_id AS Id \n \nfrom obs o \n-- HTS CLIENTS WITH POSITIVE HIV STATUS BY SEX AND AGE \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND o.concept_id = 2165 and o.value_coded = 1738 \nAND patient.voided = 0 AND o.voided = 0 \nAND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n-- CLIENT INITIATED TESTING AND COUNSELING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 4228 and os.value_coded = 4226 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \n-- REPEAT TESTER, HAVE A HISTORY OF PREVIOUS TESTING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 2137 and os.value_coded = 2146 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \nINNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n-- Observations inside the HIV Testing and Couseling Form \nAND o.obs_group_id in ( \nselect og.obs_id from obs og where og.concept_id = 2385 \n) \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location)\n','2020-04-27 10:58:31',4,'2021-07-22 23:41:40',4,0,NULL,NULL,NULL,'3b0f9835-29a4-418d-aaa6-3f8f1d141ece'),(469,'CITC_Repeat_Negative','clients tested negative on repeat visit','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative\n clients tested negative on repeat visit\n \n 2020-04-27 05:30:31 UTC\n \n 2021-07-22 18:10: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 469\n select distinct patient.patient_id AS Id \n \nfrom obs o \n-- HTS CLIENTS WITH NEGATIVE HIV STATUS BY SEX AND AGE \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND o.concept_id = 2165 and o.value_coded = 1016 \nAND patient.voided = 0 AND o.voided = 0 \nAND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n-- CLIENT INITIATED TESTING AND COUNSELING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 4228 and os.value_coded = 4226 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \n-- REPEAT TESTER, HAVE A HISTORY OF PREVIOUS TESTING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 2137 and os.value_coded = 2146 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \nINNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n-- Observations inside the HIV Testing and Couseling Form \nAND o.obs_group_id in ( \nselect og.obs_id from obs og where og.concept_id = 2385 \n) \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location)\n','2020-04-27 11:00:31',4,'2021-07-22 23:40:47',4,0,NULL,NULL,NULL,'a4daa5d2-8e61-44d1-bc37-1b6aba7a6d55'),(470,'CITC_New_Positive','new clients tested positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive\n new clients tested positive\n \n 2020-04-27 05:33:15 UTC\n \n 2021-07-22 18:09: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 470\n select distinct patient.patient_id AS Id \n \nfrom obs o \n-- HTS CLIENTS WITH POSITIVE HIV STATUS BY SEX AND AGE \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND o.concept_id = 2165 and o.value_coded = 1738 \nAND patient.voided = 0 AND o.voided = 0 \nAND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n-- CLIENT INITIATED TESTING AND COUNSELING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 4228 and os.value_coded = 4226 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \n-- NEW TESTER, AVE A HISTORY OF PREVIOUS TESTING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 2137 and os.value_coded = 2147 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \nINNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n-- Observations inside the HIV Testing and Couseling Form \nAND o.obs_group_id in ( \nselect og.obs_id from obs og where og.concept_id = 2385 \n) \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location)\n','2020-04-27 11:03:15',4,'2021-07-22 23:39:48',4,0,NULL,NULL,NULL,'9cd47068-2982-4ca1-a040-bc19ca313349'),(471,'CITC_New_Negative','clients tested negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative\n clients tested negative\n \n 2020-04-27 05:37:47 UTC\n \n 2021-07-22 18:05: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 471\n Select distinct patient.patient_id AS Id \n \nfrom obs o \n-- HTS CLIENTS WITH NEGATIVE HIV STATUS BY SEX AND AGE \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND o.concept_id = 2165 and o.value_coded = 1016 \nAND patient.voided = 0 AND o.voided = 0 \nAND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n-- CLIENT INITIATED TESTING AND COUNSELING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 4228 and os.value_coded = 4226 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \n-- NEW TESTER, AVE A HISTORY OF PREVIOUS TESTING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 2137 and os.value_coded = 2147 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \nINNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n-- Observations inside the HIV Testing and Couseling Form \nAND o.obs_group_id in ( \nselect og.obs_id from obs og where og.concept_id = 2385 \n) \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location)\n','2020-04-27 11:07:47',4,'2021-07-22 23:35:11',4,0,NULL,NULL,NULL,'ebf8843c-2e45-4156-8bbf-867273775513'),(472,'CITC New Positive','CITC New Positive','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC New Positive\n CITC New Positive\n \n 2020-04-27 05:39:50 UTC\n \n 2020-04-27 05:41: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 472\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-04-27 05:39:50',4,'2020-04-27 05:41:21',4,0,NULL,NULL,NULL,'512d2da0-391c-4ec8-b8cc-d9f3028bf456'),(473,'CITC New Negative','CITC New Negative','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC New Negative\n CITC New Negative\n \n 2020-04-27 05:42:28 UTC\n \n 2020-04-27 05: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 473\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-04-27 05:42:28',4,'2020-04-27 05:44:08',4,0,NULL,NULL,NULL,'2c87a371-a86c-4980-aade-4303463e95a5'),(474,'CITC Repeat Positive','CITC Repeat Positive','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC Repeat Positive\n CITC Repeat Positive\n \n 2020-04-27 05:46:33 UTC\n \n 2020-04-27 05:47: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 474\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-04-27 05:46:33',4,'2020-04-27 05:47:32',4,0,NULL,NULL,NULL,'71f59662-0e07-40f6-9c6c-0570bc3ef36f'),(475,'CITC Repeat Negative','CITC Repeat Negative','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC Repeat Negative\n CITC Repeat Negative\n \n 2020-04-27 05:50:11 UTC\n \n 2020-04-27 05:54: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 475\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-04-27 05:50:11',4,'2020-04-27 05:54:46',4,0,NULL,NULL,NULL,'e42b4a1d-bc07-4ab9-b60b-30896100d112'),(476,'CITC','Client Initiated Testing and Counseling section of HTS form','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC\n Client Initiated Testing and Counseling section of HTS form\n \n 2020-04-27 05:56:14 UTC\n \n 2020-04-27 05: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 476\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','2020-04-27 05:56:14',4,'2020-04-27 05:56:21',4,0,NULL,NULL,NULL,'87d3cf9f-40bc-4516-960e-03c17a6b6a09'),(477,'CITC Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC Data Set\n \n 2020-04-27 05:56:21 UTC\n \n 2020-04-27 10:39: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 477\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 CInewNe14F\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 10to14yrs\n \n \n \n \n \n CInewNe14M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n CInewNe19F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n CInewNe19M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n CInewNe24F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n CInewNe24M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n CInewNe29F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 25to29yrs\n \n \n \n \n \n CInewNe29M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 25to29yrs\n \n \n \n \n \n CInewNe34F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 30to34yrs\n \n \n \n \n \n CInewNe34M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 30to34yrs\n \n \n \n \n \n CInewNe39F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 35to39yrs\n \n \n \n \n \n CInewNe39M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 35to39yrs\n \n \n \n \n \n CInewNe44F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 40to44yrs\n \n \n \n \n \n CInewNe44M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 40to44yrs\n \n \n \n \n \n CInewNe49F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 45to49yrs\n \n \n \n \n \n CInewNe49M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 45to49yrs\n \n \n \n \n \n CInewNe50F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 50to100yrs\n \n \n \n \n \n CInewNe50M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 50to100yrs\n \n \n \n \n \n CInewNeg1F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n CInewNeg1M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n CInewNeg4F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n CInewNeg4M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n CInewNeg9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n CInewNeg9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n CInewPo14F\n \n \n \n \n \n \n \n \n \n CInewPo14M\n \n \n \n \n \n \n CInewPo19F\n \n \n \n \n \n \n CInewPo19M\n \n \n \n \n \n \n CInewPo24F\n \n \n \n \n \n \n CInewPo24M\n \n \n \n \n \n \n CInewPo29F\n \n \n \n \n \n \n CInewPo29M\n \n \n \n \n \n \n CInewPo34F\n \n \n \n \n \n \n CInewPo34M\n \n \n \n \n \n \n CInewPo39F\n \n \n \n \n \n \n CInewPo39M\n \n \n \n \n \n \n CInewPo44F\n \n \n \n \n \n \n CInewPo44M\n \n \n \n \n \n \n CInewPo49F\n \n \n \n \n \n \n CInewPo49M\n \n \n \n \n \n \n CInewPo50F\n \n \n \n \n \n \n CInewPo50M\n \n \n \n \n \n \n CInewPos1F\n \n \n \n \n \n \n CInewPos1M\n \n \n \n \n \n \n CInewPos4F\n \n \n \n \n \n \n CInewPos4M\n \n \n \n \n \n \n CInewPos9F\n \n \n \n \n \n \n CInewPos9M\n \n \n \n \n \n \n CIrepNe14F\n \n \n \n \n \n \n \n \n \n CIrepNe14M\n \n \n \n \n \n \n CIrepNe19F\n \n \n \n \n \n \n CIrepNe19M\n \n \n \n \n \n \n CIrepNe24F\n \n \n \n \n \n \n CIrepNe24M\n \n \n \n \n \n \n CIrepNe29F\n \n \n \n \n \n \n CIrepNe29M\n \n \n \n \n \n \n CIrepNe34F\n \n \n \n \n \n \n CIrepNe34M\n \n \n \n \n \n \n \n \n \n CIrepNe39F\n \n \n \n \n \n \n CIrepNe39M\n \n \n \n \n \n \n CIrepNe44F\n \n \n \n \n \n \n CIrepNe44M\n \n \n \n \n \n \n CIrepNe49F\n \n \n \n \n \n \n CIrepNe49M\n \n \n \n \n \n \n CIrepNe50F\n \n \n \n \n \n \n CIrepNe50M\n \n \n \n \n \n \n CIrepNeg1F\n \n \n \n \n \n \n CIrepNeg1M\n \n \n \n \n \n \n CIrepNeg4F\n \n \n \n \n \n \n CIrepNeg4M\n \n \n \n \n \n \n CIrepNeg9F\n \n \n \n \n \n \n CIrepNeg9M\n \n \n \n \n \n \n CIrepPo14F\n \n \n \n \n \n \n CIrepPo14M\n \n \n \n \n \n \n CIrepPo19F\n \n \n \n \n \n \n CIrepPo19M\n \n \n \n \n \n \n CIrepPo24F\n \n \n \n \n \n \n CIrepPo24M\n \n \n \n \n \n \n CIrepPo29F\n \n \n \n \n \n \n CIrepPo29M\n \n \n \n \n \n \n CIrepPo34F\n \n \n \n \n \n \n CIrepPo34M\n \n \n \n \n \n \n CIrepPo39F\n \n \n \n \n \n \n CIrepPo39M\n \n \n \n \n \n \n CIrepPo44F\n \n \n \n \n \n \n CIrepPo44M\n \n \n \n \n \n \n CIrepPo49F\n \n \n \n \n \n \n CIrepPo49M\n \n \n \n \n \n \n CIrepPo50F\n \n \n \n \n \n \n CIrepPo50M\n \n \n \n \n \n \n CIrepPos1F\n \n \n \n \n \n \n CIrepPos1M\n \n \n \n \n \n \n CIrepPos4F\n \n \n \n \n \n \n CIrepPos4M\n \n \n \n \n \n \n CIrepPos9F\n \n \n \n \n \n \n CIrepPos9M\n \n \n \n \n \n \n','2020-04-27 05:56:21',4,'2020-04-27 10:39:40',4,0,NULL,NULL,NULL,'3b4a124e-e541-4655-bce1-07595881f037'),(478,'HTS Indeterminate','total inderminate results','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Indeterminate\n total inderminate results\n \n 2020-05-03 10:54:09 UTC\n \n 2020-05-03 10:55: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 478\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.concept_id = 4223 and value_coded = 4220) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 10:54:09',4,'2020-05-03 10:55:12',4,0,NULL,NULL,NULL,'9d8d2a02-6b1b-4f6f-9897-7f2440d60bf5'),(479,'HTS Couple','couples','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Couple\n couples\n \n 2020-05-03 10:58:12 UTC\n \n 2020-05-03 10:59: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 479\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.concept_id = 2166 and value_coded = 2146) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 10:58:12',4,'2020-05-03 10:59:17',4,0,NULL,NULL,NULL,'361c4fa5-4375-42da-935b-00cf7a975167'),(480,'HTS Discordant','Discordant test results','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Discordant\n Discordant test results\n \n 2020-05-03 11:00:30 UTC\n \n 2022-03-17 08:39: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 480\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 concept_id = 2164 \nand person_id in (select person_id from obs where (concept_id = 4225 and value_coded = 2146) \n and obs_datetime >=:startDate \n and obs_datetime <=:endDate \n ) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 11:00:30',4,'2022-03-17 08:39:24',4,0,NULL,NULL,NULL,'49027ad5-be0a-45f5-af20-0926fb6adec9'),(481,'HTS Screened','Clients screened for TB','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Screened\n Clients screened for TB\n \n 2020-05-03 11:05:45 UTC\n \n 2020-05-03 11: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 481\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.concept_id = 2294 and value_coded = 2146) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 11:05:45',4,'2020-05-03 11:06:26',4,0,NULL,NULL,NULL,'3aadefe4-1302-4fff-a140-55a0a634f093'),(482,'HTS Male Condoms','Male condoms distributed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Male Condoms\n Male condoms distributed\n \n 2020-05-03 11:07:57 UTC\n \n 2020-05-03 11:12: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 482\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.concept_id = 4231 and value_coded = 4229) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 11:07:57',4,'2020-05-03 11:12:28',4,0,NULL,NULL,NULL,'9b9b6440-4e3a-4bc4-93eb-e52f32f36cc8'),(483,'HTS Female Condoms','Female condoms distributed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Female Condoms\n Female condoms distributed\n \n 2020-05-03 11:13:25 UTC\n \n 2020-05-03 11:14: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 483\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.concept_id = 4231 and value_coded = 4230) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 11:13:25',4,'2020-05-03 11:14:03',4,0,NULL,NULL,NULL,'18f0954d-4c76-4a30-92e8-306c93bb1b98'),(484,'HTS Confirmatory Negative','COnfirmatory test results negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Confirmatory Negative\n COnfirmatory test results negative\n \n 2020-05-03 11:18:07 UTC\n \n 2020-05-03 11: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 484\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.concept_id = 2161 and value_coded = 1016) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 11:18:07',4,'2020-05-03 11:19:20',4,0,NULL,NULL,NULL,'1ec73fb7-2046-4706-bb66-109eb6ec94c3'),(485,'HTS Confirmatory Positive','Confirmatory test results positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Confirmatory Positive\n Confirmatory test results positive\n \n 2020-05-03 11:21:28 UTC\n \n 2020-05-03 11: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 485\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.concept_id = 2161 and value_coded = 1738) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 11:21:28',4,'2020-05-03 11:22:06',4,0,NULL,NULL,NULL,'78a1c404-42d9-469d-9220-b873114308c2'),(486,'HTS SelfTest Kits','HIVST confirmed HIV positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS SelfTest Kits\n HIVST confirmed HIV positive\n \n 2020-05-03 11:23:54 UTC\n \n 2020-05-03 11: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 486\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.concept_id = 2161 and value_coded = 1738) \nand person_id in (select person_id \nfrom obs \nwhere concept_id = 4662 and value_coded = 4237 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 11:23:54',4,'2020-05-03 11:26:06',4,0,NULL,NULL,NULL,'1377634a-611f-45c3-b42b-0ff16dec16eb'),(487,'HTS Indeterminate','total indeterminate results','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Indeterminate\n total indeterminate results\n \n 2020-05-03 19:06:01 UTC\n \n 2020-05-03 19:07: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 487\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 19:06:01',4,'2020-05-03 19:07:14',4,0,NULL,NULL,NULL,'cbc0f41b-11d1-42c5-819d-2b256a192c7a'),(488,'HTS Couple','Couples only','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Couple\n Couples only\n \n 2020-05-03 19:09:15 UTC\n \n 2020-05-03 19:09: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 488\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 19:09:15',4,'2020-05-03 19:09:57',4,0,NULL,NULL,NULL,'4eae8f2e-2b61-4b25-91f4-027131d2a8e7'),(489,'HTS Discordant','Discordant test results','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Discordant\n Discordant test results\n \n 2020-05-03 19:12:07 UTC\n \n 2020-05-03 19: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 489\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 19:12:07',4,'2020-05-03 19:12:54',4,0,NULL,NULL,NULL,'42279637-8cd0-4097-8948-7ac931af776b'),(490,'HTS Screened','HTS clients screened for TB','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Screened\n HTS clients screened for TB\n \n 2020-05-03 19:13:57 UTC\n \n 2022-03-17 14:20: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 490\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 19:13:57',4,'2022-03-17 14:20:03',4,0,NULL,NULL,NULL,'80d07406-6d62-4289-8d32-887363807775'),(491,'HTS Female Condoms distributed','Condoms distributed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Female Condoms distributed\n Condoms distributed\n \n 2020-05-03 19:18:56 UTC\n \n 2020-05-03 19: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 491\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 19:18:56',4,'2020-05-03 19:21:45',4,0,NULL,NULL,NULL,'9c177ce6-5697-4b84-9093-8e30ac78e3e3'),(492,'HTS Male Condoms','Male condoms distributed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Male Condoms\n Male condoms distributed\n \n 2020-05-03 19:22:24 UTC\n \n 2020-05-03 19:23: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 492\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 19:22:24',4,'2020-05-03 19:23:18',4,0,NULL,NULL,NULL,'5c760a04-22f9-40aa-94a5-397340c8b638'),(493,'HTS Confirmatory Negative','Confirmatory Negative','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Confirmatory Negative\n Confirmatory Negative\n \n 2020-05-03 19:24:40 UTC\n \n 2020-05-03 19:25: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 493\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 19:24:40',4,'2020-05-03 19:25:28',4,0,NULL,NULL,NULL,'f1f06a0f-0afb-4aaa-8542-dd54ff94b6ce'),(494,'HTS Confirmatory Positive','Confirmatory Positive','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Confirmatory Positive\n Confirmatory Positive\n \n 2020-05-03 19:26:24 UTC\n \n 2020-05-03 19:27: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 494\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 19:26:24',4,'2020-05-03 19:27:46',4,0,NULL,NULL,NULL,'5fefbf51-d124-4c3d-a6bd-69bfb0b78f64'),(495,'HTS Self Test Kits','Self Test Kits','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Self Test Kits\n Self Test Kits\n \n 2020-05-03 19:29:29 UTC\n \n 2021-10-19 12:01: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 495\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 21:29:29',4,'2021-10-19 14:01:42',4,0,NULL,NULL,NULL,'89fdd6f1-5744-4a2b-9d08-00ef77bb50d8'),(496,'HTS Period Indicator Report','indeterminate,couples,discordant couples,screened for TB,Condoms distribution and confirmatory test results','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Period Indicator Report\n indeterminate,couples,discordant couples,screened for TB,Condoms distribution and confirmatory test results\n \n 2020-05-03 19:38:28 UTC\n \n 2020-05-03 19:38: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 496\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','2020-05-03 19:38:28',4,'2020-05-03 19:38:31',4,0,NULL,NULL,NULL,'dafef277-1393-484d-a947-936a507e03a1'),(497,'HTS Period Indicator 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 HTS Period Indicator Report Data Set\n \n 2020-05-03 19:38:31 UTC\n \n 2020-05-26 13:54: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 497\n \n \n DM_Sex\n \n \n \n \n \n \n \n \n Confirm_N\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 Confirm_P\n \n \n \n \n \n \n \n \n \n Couples\n \n \n \n \n \n \n \n \n \n Discordant\n \n \n \n \n \n \n \n \n \n DistriCD_F\n \n \n \n \n \n \n \n \n \n DistriCD_M\n \n \n \n \n \n \n \n \n \n IND_result\n \n \n \n \n \n \n \n \n \n Indetermin\n \n \n \n \n \n \n \n \n \n Screened_F\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n \n \n \n Screened_M\n \n \n \n \n DM_Sex\n Males\n \n \n \n \n \n','2020-05-03 19:38:31',4,'2020-05-26 13:54:52',4,0,NULL,NULL,NULL,'f25de016-f5c5-4638-b08c-ee3a31c63121'),(498,'HTS Self Test Report','Self Test Kits Distributed and Returned','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Self Test Report\n Self Test Kits Distributed and Returned\n \n 2020-05-03 19:50:04 UTC\n \n 2022-03-09 07:17: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 498\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','2020-05-04 01:20:04',4,'2022-03-09 12:47:59',4,0,NULL,NULL,NULL,'92c28a1a-1d44-40b4-b11f-61a620cea4ea'),(499,'HTS Self Test Kits Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Self Test Kits Data Set\n \n 2020-05-03 19:50:07 UTC\n \n 2022-04-05 07:47: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 499\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 Dis10to14F\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 10to14yrs\n \n \n \n \n \n Dis10to14M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n Dis15+_M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n Dis15to19F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n Dis15to19M\n \n \n \n \n \n \n Dis20to24F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n Dis20to24M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n Dis25to29F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 25to29yrs\n \n \n \n \n \n Dis25to29M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 25to29yrs\n \n \n \n \n \n Dis30to34F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 30to34yrs\n \n \n \n \n \n Dis30to34M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 30to34yrs\n \n \n \n \n \n Dis35to39F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 35to39yrs\n \n \n \n \n \n Dis35to39M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 35to39yrs\n \n \n \n \n \n Dis40to44F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 40to44yrs\n \n \n \n \n \n Dis40to44M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 40to44yrs\n \n \n \n \n \n Dis45to49F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 45to49yrs\n \n \n \n \n \n Dis45to49M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 45to49yrs\n \n \n \n \n \n Dis50_F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 50to100yrs\n \n \n \n \n \n Dis50_M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 50to100yrs\n \n \n \n \n \n Po10to14_F\n \n \n \n \n \n \n \n \n \n Po10to14_M\n \n \n \n \n \n \n Po15to19_F\n \n \n \n \n \n \n Po15to19_M\n \n \n \n \n \n \n Po20to24_F\n \n \n \n \n \n \n Po20to24_M\n \n \n \n \n \n \n Po25to29_F\n \n \n \n \n \n \n Po25to29_M\n \n \n \n \n \n \n Po30to34_F\n \n \n \n \n \n \n Po30to34_M\n \n \n \n \n \n \n Po35to39_F\n \n \n \n \n \n \n Po35to39_M\n \n \n \n \n \n \n Po40to44_F\n \n \n \n \n \n \n Po40to44_M\n \n \n \n \n \n \n Po45to49_F\n \n \n \n \n \n \n Po45to49_M\n \n \n \n \n \n \n Po50_F\n \n \n \n \n \n \n Po50_M\n \n \n \n \n \n \n Ret10to14F\n \n \n \n \n \n \n \n \n \n Ret10to14M\n \n \n \n \n \n \n Ret15to19F\n \n \n \n \n \n \n Ret15to19M\n \n \n \n \n \n \n Ret20to24F\n \n \n \n \n \n \n Ret20to24M\n \n \n \n \n \n \n Ret25to29F\n \n \n \n \n \n \n Ret25to29M\n \n \n \n \n \n \n Ret30to34F\n \n \n \n \n \n \n Ret30to34M\n \n \n \n \n \n \n Ret35to39F\n \n \n \n \n \n \n Ret35to39M\n \n \n \n \n \n \n Ret40to44F\n \n \n \n \n \n \n Ret40to44M\n \n \n \n \n \n \n Ret45to49F\n \n \n \n \n \n \n Ret45to49M\n \n \n \n \n \n \n Ret50_F\n \n \n \n \n \n \n Ret50_M\n \n \n \n \n \n \n','2020-05-03 19:50:07',4,'2022-04-05 07:47:13',4,0,NULL,NULL,NULL,'613de36b-b418-42b6-b2db-37cd706fc3fd'),(500,'HTS Indeterminate results','results indeterminate','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Indeterminate results\n results indeterminate\n \n 2020-05-26 13:50:27 UTC\n \n 2020-05-26 13:53: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 500\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-26 13:50:27',4,'2020-05-26 13:53:47',4,0,NULL,NULL,NULL,'c15c5dfa-0d7e-463f-a69d-95576f0ebdba'),(501,'HTS Indeterminate results','results indeterminate','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Indeterminate results\n results indeterminate\n \n 2020-05-26 13:52:43 UTC\n \n 2020-05-26 13: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 501\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.concept_id = 4223 and value_coded = 4220) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-26 13:52:43',4,'2020-05-26 13:52:53',4,0,NULL,NULL,NULL,'e5b3353e-8bf6-483a-95a4-cc15c2df3ec9'),(502,'adult_arv_1c_1mnth','clients given 1month supply of 1c ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1c_1mnth\n clients given 1month supply of 1c \n \n 2020-06-04 10:51:42 UTC\n \n 2020-06-04 11:05: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 502\n select distinct o.person_id \nfrom obs o \ninner join (select o.person_id \n from obs o \n inner join \n (select person_id,max(obs_datetime) maxdate \n from obs a \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2201 \n group by person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 2250 and value_coded = 2201 \n and obs_datetime BETWEEN :startDate AND :endDate \n and o.obs_datetime = maxdate \n )b on b.person_id = o.person_id \ninner join \n (select o.person_id \n from obs o \n inner join \n (select person_id,max(obs_datetime) maxdate \n from obs a \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n group by person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 4174 and value_coded = 4175 \n and obs_datetime BETWEEN :startDate AND :endDate \n and o.obs_datetime = maxdate) a on a.person_id = o.person_id \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0\n','2020-06-04 10:51:42',4,'2020-06-04 11:05:55',4,0,NULL,NULL,NULL,'0a6886b5-4642-4477-9218-319ed4782e1d'),(503,'adult_arv_1d_1mnth','clients given 1mnth supply of 1d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1d_1mnth\n clients given 1mnth supply of 1d\n \n 2020-06-04 11:07:29 UTC\n \n 2020-06-16 10: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 503\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2203 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:07:29',4,'2020-06-16 10:38:11',4,0,NULL,NULL,NULL,'d4cdfdf6-35b1-40bb-b177-9c226a164810'),(504,'adult_arv_1e_1mnth','clients given 1month supply of 1e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1e_1mnth\n clients given 1month supply of 1e\n \n 2020-06-04 11:11:23 UTC\n \n 2020-06-16 10:38: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 504\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2205 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:11:23',4,'2020-06-16 10:38:36',4,0,NULL,NULL,NULL,'3b4e39fc-f4d0-493e-b4e5-7effd305b929'),(505,'adult_arv_1f_1mnth','clients given 1month supply of 1f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1f_1mnth\n clients given 1month supply of 1f\n \n 2020-06-04 11:17:19 UTC\n \n 2020-11-20 10:16: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 505\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select person_id from \n (select currentreg.person_id,IFNULL(substitute_regimen,current_reg) ARV_regimen \n from \n (select os.person_id, os.value_coded as current_reg \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 2250 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4175) \n ) \n )currentreg \n left outer JOIN \n ( \n select os.person_id, os.value_coded as substitute_regimen \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 4284 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4175) \n ) \n )substitutereg \n on substitutereg.person_id = currentreg.person_id \n)regimen \nwhere ARV_regimen = 2207)\n','2020-06-04 13:17:19',4,'2020-11-20 12:16:19',4,0,NULL,NULL,NULL,'f059b928-f6d1-4629-87ab-2c9f1c2d4166'),(506,'adult_arv_1g_1mnth','clients given 1month supply of 1g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1g_1mnth\n clients given 1month supply of 1g\n \n 2020-06-04 11:18:32 UTC\n \n 2020-06-16 10:42: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 506\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3672 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:18:32',4,'2020-06-16 10:42:06',4,0,NULL,NULL,NULL,'3badd804-dd17-4f9f-aee1-01ebab4449b9'),(507,'adult_arv_1h_1mnth','clients given 1month supply of 1h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1h_1mnth\n clients given 1month supply of 1h\n \n 2020-06-04 11:20:23 UTC\n \n 2020-06-16 10:42: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 507\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3673 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:20:23',4,'2020-06-16 10:42:34',4,0,NULL,NULL,NULL,'4263e276-f261-406b-bcd0-56cda9464190'); -INSERT INTO `serialized_object` VALUES (508,'adult_arv_1j_1mnth','clients given 1 month supply of 1j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1j_1mnth\n clients given 1 month supply of 1j\n \n 2020-06-04 11:22:33 UTC\n \n 2020-11-20 10:56: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 508\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select person_id from \n (select currentreg.person_id,IFNULL(substitute_regimen,current_reg) ARV_regimen \n from \n (select os.person_id, os.value_coded as current_reg \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 2250 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4175) \n ) \n )currentreg \n left outer JOIN \n ( \n select os.person_id, os.value_coded as substitute_regimen \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 4284 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4175) \n ) \n )substitutereg \n on substitutereg.person_id = currentreg.person_id \n)regimen \nwhere ARV_regimen = 4678)\n','2020-06-04 13:22:33',4,'2020-11-20 12:56:17',4,0,NULL,NULL,NULL,'dd8a7cca-c5ee-4aba-8064-4fbe4ab6b3f1'),(509,'adult_arv_1k_1mnth','clients given 1month supply of 1k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1k_1mnth\n clients given 1month supply of 1k\n \n 2020-06-04 11:23:48 UTC\n \n 2020-06-16 10: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 509\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4679 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:23:48',4,'2020-06-16 10:44:08',4,0,NULL,NULL,NULL,'2b7d8866-e84b-4ccf-9ffa-1707557910f1'),(510,'adult_arv_1m_1mnth','clients given 1month supply of 1m','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1m_1mnth\n clients given 1month supply of 1m\n \n 2020-06-04 11:26:24 UTC\n \n 2020-06-16 10:45: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 510\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4680 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:26:24',4,'2020-06-16 10:45:33',4,0,NULL,NULL,NULL,'8b668641-8cd1-4710-9900-e14afa11d477'),(511,'adult_arv_1n_1mnth','clients given 1month supply of 1n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1n_1mnth\n clients given 1month supply of 1n\n \n 2020-06-04 11:27:29 UTC\n \n 2020-06-16 10: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 511\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4681 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:27:29',4,'2020-06-16 10:45:05',4,0,NULL,NULL,NULL,'a22dae13-6bc7-4d24-9e4d-a0fefab2c9fd'),(512,'adult_arv_1p_1mnth','clients given 1month supply of 1p','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1p_1mnth\n clients given 1month supply of 1p\n \n 2020-06-04 11:30:16 UTC\n \n 2020-06-16 10:46: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 512\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4682 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:30:16',4,'2020-06-16 10:46:13',4,0,NULL,NULL,NULL,'a1837be3-878d-423d-8684-808738f28305'),(513,'adult_arv_1q_1mnth','clients given 1 month supply of 1q','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1q_1mnth\n clients given 1 month supply of 1q\n \n 2020-06-04 11:31:28 UTC\n \n 2020-06-16 10:46: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 513\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4683 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:31:28',4,'2020-06-16 10:46:57',4,0,NULL,NULL,NULL,'c4e93e64-91fe-48e4-a432-8553a70a138b'),(514,'adult_arv_other_1mnth','clients given 1month supply of other arv','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_other_1mnth\n clients given 1month supply of other arv\n \n 2020-06-04 11:35:49 UTC\n \n 2020-06-16 10:48: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 514\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2143 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:35:49',4,'2020-06-16 10:48:03',4,0,NULL,NULL,NULL,'7c04bae3-26e2-44bb-9f14-46bd23abf3b7'),(515,'adult_arv_1c_3mnth','3mnths supply of 1c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1c_3mnth\n 3mnths supply of 1c\n \n 2020-06-04 11:41:08 UTC\n \n 2020-06-16 10:49: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 515\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2201 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 11:41:08',4,'2020-06-16 10:49:04',4,0,NULL,NULL,NULL,'238a43b6-79ac-46a7-907f-a1e351c5caaa'),(516,'adult_arv_1d_3mnth','3mnths supply of 1d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1d_3mnth\n 3mnths supply of 1d\n \n 2020-06-04 11:42:06 UTC\n \n 2020-06-16 10:49: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 516\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2203 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 11:42:06',4,'2020-06-16 10:49:30',4,0,NULL,NULL,NULL,'1e1e9500-f32d-4290-aab4-935a88bfe130'),(517,'adult_arv_1e_3mnth','3mnths supply of 1e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1e_3mnth\n 3mnths supply of 1e\n \n 2020-06-04 11:46:30 UTC\n \n 2020-06-16 10:49: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 517\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2205 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 11:46:30',4,'2020-06-16 10:49:53',4,0,NULL,NULL,NULL,'db80a24f-af5f-4553-bc8c-9958d082feb4'),(518,'adult_arv_1f_3mnth','3mnths supply of 1f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1f_3mnth\n 3mnths supply of 1f\n \n 2020-06-04 11:48:17 UTC\n \n 2020-11-20 10:53: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 518\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select person_id from \n (select currentreg.person_id,IFNULL(substitute_regimen,current_reg) ARV_regimen \n from \n (select os.person_id, os.value_coded as current_reg \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 2250 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4177) \n ) \n )currentreg \n left outer JOIN \n ( \n select os.person_id, os.value_coded as substitute_regimen \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 4284 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4177) \n ) \n )substitutereg \n on substitutereg.person_id = currentreg.person_id \n)regimen \nwhere ARV_regimen = 2207)\n','2020-06-04 13:48:17',4,'2020-11-20 12:53:53',4,0,NULL,NULL,NULL,'22c820ef-4629-49cb-8ca1-bd2b25c3ff59'),(519,'adult_arv_1g_3mnth','3mnths supply of 1g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1g_3mnth\n 3mnths supply of 1g\n \n 2020-06-04 11:49:57 UTC\n \n 2020-06-16 10:51: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 519\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3672 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 11:49:57',4,'2020-06-16 10:51:22',4,0,NULL,NULL,NULL,'b048d9e0-11c1-4092-8c31-ba6e3acea989'),(520,'adult_arv_1h_3mnth','3mnths supply of 1h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1h_3mnth\n 3mnths supply of 1h\n \n 2020-06-04 11:55:26 UTC\n \n 2020-06-04 11: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 520\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3673 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 11:55:26',4,'2020-06-04 11:57:44',4,0,NULL,NULL,NULL,'1ff080c3-e4fb-4884-bcdb-431d8cf59157'),(521,'adult_arv_1j_3mnth','3mnths supply of 1j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1j_3mnth\n 3mnths supply of 1j\n \n 2020-06-04 11:59:08 UTC\n \n 2020-11-20 10:49: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 521\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select person_id from \n (select currentreg.person_id,IFNULL(substitute_regimen,current_reg) ARV_regimen \n from \n (select os.person_id, os.value_coded as current_reg \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 2250 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4177) \n ) \n )currentreg \n left outer JOIN \n ( \n select os.person_id, os.value_coded as substitute_regimen \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 4284 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4177) \n ) \n )substitutereg \n on substitutereg.person_id = currentreg.person_id \n)regimen \nwhere ARV_regimen = 4678)\n','2020-06-04 13:59:08',4,'2020-11-20 12:49:56',4,0,NULL,NULL,NULL,'5ed7e3c1-afba-4802-a334-a611a9102cc5'),(522,'adult_arv_1k_3mnth','3mnths supply of 1k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1k_3mnth\n 3mnths supply of 1k\n \n 2020-06-04 13:10:45 UTC\n \n 2020-06-04 13:21: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 522\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4679 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 13:10:45',4,'2020-06-04 13:21:56',4,0,NULL,NULL,NULL,'5ee29b38-8294-44d6-bca4-6fd3a2e668ed'),(523,'adult_arv_1m_3mnth','3mnths supply of 1m','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1m_3mnth\n 3mnths supply of 1m\n \n 2020-06-04 13:23:09 UTC\n \n 2020-06-04 13:24: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 523\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4680 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 13:23:09',4,'2020-06-04 13:24:04',4,0,NULL,NULL,NULL,'063a7963-5a7f-4ab4-a444-0db599f8c5a8'),(524,'adult_arv_1n_3mnth','3mnths supply of 1n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1n_3mnth\n 3mnths supply of 1n\n \n 2020-06-04 13:25:04 UTC\n \n 2020-06-04 13:25: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 524\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4681 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 13:25:04',4,'2020-06-04 13:25:38',4,0,NULL,NULL,NULL,'03237de9-f7dc-4446-a8b0-07c73bbf780b'),(525,'adult_arv_1p_3mnth','3mnths supply of 1p','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1p_3mnth\n 3mnths supply of 1p\n \n 2020-06-04 13:27:08 UTC\n \n 2020-06-04 13:27: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 525\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4682 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 13:27:08',4,'2020-06-04 13:27:34',4,0,NULL,NULL,NULL,'5224e59b-88b4-4586-81f5-11719fd1c1ee'),(526,'adult_arv_1q_3mnth','3mnths supply of 1q','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1q_3mnth\n 3mnths supply of 1q\n \n 2020-06-04 13:30:23 UTC\n \n 2020-06-04 13:30: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 526\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4683 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 13:30:23',4,'2020-06-04 13:30:44',4,0,NULL,NULL,NULL,'9cc207d2-97db-47a0-8ff5-e687843138c8'),(527,'adult_arv_other_3mnth','3mnths supply of other regimen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_other_3mnth\n 3mnths supply of other regimen\n \n 2020-06-04 13:34:17 UTC\n \n 2020-06-04 13:34: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 527\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4679 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 13:34:17',4,'2020-06-04 13:34:55',4,0,NULL,NULL,NULL,'4d6e10d0-413f-4647-941a-3ae707d69e4d'),(528,'adult_arv_1c_6mnth','6mnths supply of 1c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1c_6mnth\n 6mnths supply of 1c\n \n 2020-06-04 13:45:59 UTC\n \n 2020-06-05 07: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 528\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2201 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 15:45:59',4,'2020-06-05 09:42:05',4,0,NULL,NULL,NULL,'8f096880-4dfb-4ef9-9234-f1ad19ed9fbd'),(529,'adult_arv_1d_6mnth','6mnths supply of 1d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1d_6mnth\n 6mnths supply of 1d\n \n 2020-06-04 13:47:33 UTC\n \n 2020-06-05 07:42: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 529\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2203 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 15:47:33',4,'2020-06-05 09:42:33',4,0,NULL,NULL,NULL,'fdb3a5d9-0f52-4594-862d-32a7067bbf33'),(530,'adult_arv_1e_6mnth','6mnths supply of 1e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1e_6mnth\n 6mnths supply of 1e\n \n 2020-06-04 13:51:21 UTC\n \n 2020-07-15 00:44: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 530\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nand o.person_id in (select os.person_id \n from obs os \n where os.obs_datetime BETWEEN :startDate AND :endDate \n and os.concept_id = 2250 and os.value_coded = 2205 \n ) \nand o.person_id in \n (select os.person_id \n from obs os \n where os.obs_datetime BETWEEN :startDate AND :endDate \n and os.concept_id = 4174 and os.value_coded = 4247 \n) \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0\n','2020-06-04 13:51:21',4,'2020-07-15 00:44:56',4,0,NULL,NULL,NULL,'13ec01be-4c41-4cab-8776-03c2be53fb90'),(531,'adult_arv_1f_6mnth','6mnths supply of 1f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1f_6mnth\n 6mnths supply of 1f\n \n 2020-06-04 13:53:31 UTC\n \n 2020-11-20 10: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 531\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select person_id from \n (select currentreg.person_id,IFNULL(substitute_regimen,current_reg) ARV_regimen \n from \n (select os.person_id, os.value_coded as current_reg \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 2250 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4247) \n ) \n )currentreg \n left outer JOIN \n ( \n select os.person_id, os.value_coded as substitute_regimen \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 4284 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4247) \n ) \n )substitutereg \n on substitutereg.person_id = currentreg.person_id \n)regimen \nwhere ARV_regimen = 2207)\n','2020-06-04 15:53:31',4,'2020-11-20 12:54:18',4,0,NULL,NULL,NULL,'87396003-00c4-433b-b3c1-eb201bd2775c'),(532,'adult_arv_1g_6mnth','6mnths supply of 1g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1g_6mnth\n 6mnths supply of 1g\n \n 2020-06-04 13:54:26 UTC\n \n 2020-06-05 07:44: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 532\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3672 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 15:54:26',4,'2020-06-05 09:44:36',4,0,NULL,NULL,NULL,'884dbb74-6589-4ee4-85af-a349f88cb8e1'),(533,'adult_arv_1h_6mnth','6mnths supply of 1h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1h_6mnth\n 6mnths supply of 1h\n \n 2020-06-04 13:55:28 UTC\n \n 2020-06-16 10:59: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 533\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3673 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 13:55:28',4,'2020-06-16 10:59:55',4,0,NULL,NULL,NULL,'dc3ece21-bfe0-4460-9c09-a12a1663b679'),(534,'adult_arv_1j_6mnth','6mnths supply of 1j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1j_6mnth\n 6mnths supply of 1j\n \n 2020-06-04 13:57:18 UTC\n \n 2020-11-20 10:57: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 534\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select person_id from \n (select currentreg.person_id,IFNULL(substitute_regimen,current_reg) ARV_regimen \n from \n (select os.person_id, os.value_coded as current_reg \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 2250 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4247) \n ) \n )currentreg \n left outer JOIN \n ( \n select os.person_id, os.value_coded as substitute_regimen \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 4284 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4247) \n ) \n )substitutereg \n on substitutereg.person_id = currentreg.person_id \n)regimen \nwhere ARV_regimen = 4678)\n','2020-06-04 15:57:18',4,'2020-11-20 12:57:08',4,0,NULL,NULL,NULL,'4becb473-e1ce-4e72-b4e2-9cf84fcc2366'),(535,'adult_arv_1k_6mnth','6mnths supply of 1k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1k_6mnth\n 6mnths supply of 1k\n \n 2020-06-04 13:58:40 UTC\n \n 2020-06-05 07:46: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 535\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4679 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 15:58:40',4,'2020-06-05 09:46:03',4,0,NULL,NULL,NULL,'3f9ce8e5-1b4a-49b0-bc6d-decfb8fb88c1'),(536,'adult_arv_1m_6mnth','6mnths supply of 1m','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1m_6mnth\n 6mnths supply of 1m\n \n 2020-06-04 14:00:09 UTC\n \n 2020-06-05 07:46: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 536\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4680 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 16:00:09',4,'2020-06-05 09:46:33',4,0,NULL,NULL,NULL,'d7b93a16-4442-49c0-817c-8a1c4b7097ca'),(537,'adult_arv_1n_6mnth','6mnths supply of 1n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1n_6mnth\n 6mnths supply of 1n\n \n 2020-06-04 14:01:31 UTC\n \n 2020-06-05 07:47: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 537\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4681 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 16:01:31',4,'2020-06-05 09:47:14',4,0,NULL,NULL,NULL,'9d4cbcb3-f873-45bf-b00f-32556db829f7'),(538,'adult_arv_1p_6mnth','6mnths supply of 1p','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1p_6mnth\n 6mnths supply of 1p\n \n 2020-06-04 14:02:37 UTC\n \n 2020-06-05 07:47: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 538\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4682 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 16:02:37',4,'2020-06-05 09:47:37',4,0,NULL,NULL,NULL,'6c977b93-8224-48bd-bfcc-fbb1430524ee'),(539,'adult_arv_1q_6mnth','6mnths supply of 1q','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1q_6mnth\n 6mnths supply of 1q\n \n 2020-06-04 14:04:18 UTC\n \n 2020-06-05 07:47: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 539\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4683 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 16:04:18',4,'2020-06-05 09:47:57',4,0,NULL,NULL,NULL,'3925978c-31f1-42dc-a61c-d4c66cb14fdd'),(540,'adult_arv_other_6mnth','6mnths supply of other regimen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_other_6mnth\n 6mnths supply of other regimen\n \n 2020-06-04 14:05:17 UTC\n \n 2020-06-05 07:48: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 540\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2143 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 16:05:17',4,'2020-06-05 09:48:28',4,0,NULL,NULL,NULL,'8b73f162-d9b5-4e96-8139-86586e839271'),(541,'adult_arv_1c_other_months','2wks,1,4,6 months supply of 1c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1c_other_months\n 2wks,1,4,6 months supply of 1c\n \n 2020-06-05 06:57:29 UTC\n \n 2020-06-05 07:48: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 541\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2201 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded in (4243,4176,4245,4246) \n)\n','2020-06-05 08:57:29',4,'2020-06-05 09:48:57',4,0,NULL,NULL,NULL,'66511f62-2da4-4c63-8641-034e01c16939'),(542,'adult_arv_1d_other_months','other durations supply of 1d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1d_other_months\n other durations supply of 1d\n \n 2020-06-05 06:58:54 UTC\n \n 2020-07-15 03: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 542\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select os.person_id \n from obs os \n where os.obs_datetime BETWEEN :startDate AND :endDate \n and os.concept_id = 2250 and os.value_coded = 2203 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where oss.obs_datetime BETWEEN :startDate AND :endDate \n and oss.concept_id = 4174 and oss.value_coded in (4243, 4176, 4245, 4246) \n ) \n)\n','2020-06-05 06:58:54',4,'2020-07-15 03:10:40',4,0,NULL,NULL,NULL,'5f87f57a-7059-49f4-986e-783823f5cbab'),(543,'adult_arv_1e_other_months','other duration supply of 1e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1e_other_months\n other duration supply of 1e\n \n 2020-06-05 06:59:45 UTC\n \n 2020-07-15 03:15: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 543\n select distinct(o.person_id) \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select os.person_id \n from obs os \n where os.obs_datetime BETWEEN :startDate AND :endDate \n and os.concept_id = 2250 and os.value_coded = 2205 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where oss.obs_datetime BETWEEN :startDate AND :endDate \n and oss.concept_id = 4174 and oss.value_coded in (4243, 4176, 4245, 4246) \n ) \n)\n','2020-06-05 06:59:45',4,'2020-07-15 03:15:48',4,0,NULL,NULL,NULL,'597e713b-7181-46ce-ae93-07605c62ec37'),(544,'adult_arv_1f_other_months','other duration supply of 1f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1f_other_months\n other duration supply of 1f\n \n 2020-06-05 07:00:40 UTC\n \n 2020-11-20 10:54: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 544\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select person_id from \n (select currentreg.person_id,IFNULL(substitute_regimen,current_reg) ARV_regimen \n from \n (select os.person_id, os.value_coded as current_reg \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 2250 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4243,4176,4245,4246) \n ) \n )currentreg \n left outer JOIN \n ( \n select os.person_id, os.value_coded as substitute_regimen \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 4284 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4243,4176,4245,4246) \n ) \n )substitutereg \n on substitutereg.person_id = currentreg.person_id \n)regimen \nwhere ARV_regimen = 2207)\n','2020-06-05 09:00:40',4,'2020-11-20 12:54:47',4,0,NULL,NULL,NULL,'c83bc608-76be-4774-8065-9e5def272804'),(545,'adult_arv_1g_other_months','other duration supply of 1g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1g_other_months\n other duration supply of 1g\n \n 2020-06-05 07:05:30 UTC\n \n 2020-06-05 07:05: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 545\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3672 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded in (4243,4176,4245,4246) \n)\n','2020-06-05 09:05:30',4,'2020-06-05 09:05:57',4,0,NULL,NULL,NULL,'da485ef1-77d0-4d3d-865d-d8011e6a7560'),(546,'adult_arv_1h_other_months','other duration suppply of 1h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1h_other_months\n other duration suppply of 1h\n \n 2020-06-05 07:06:48 UTC\n \n 2020-07-15 03:11: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 546\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select os.person_id \n from obs os \n where os.obs_datetime BETWEEN :startDate AND :endDate \n and os.concept_id = 2250 and os.value_coded = 3673 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where oss.obs_datetime BETWEEN :startDate AND :endDate \n and oss.concept_id = 4174 and oss.value_coded in (4243, 4176, 4245, 4246) \n ) \n)\n','2020-06-05 07:06:48',4,'2020-07-15 03:11:35',4,0,NULL,NULL,NULL,'4856375f-ed15-4b80-8a69-230643d6918e'),(547,'adult_arv_1j_other_months','other duration supply of 1j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1j_other_months\n other duration supply of 1j\n \n 2020-06-05 07:07:37 UTC\n \n 2020-11-20 10:57: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 547\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select person_id from \n (select currentreg.person_id,IFNULL(substitute_regimen,current_reg) ARV_regimen \n from \n (select os.person_id, os.value_coded as current_reg \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 2250 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4243,4176,4245,4246) \n ) \n )currentreg \n left outer JOIN \n ( \n select os.person_id, os.value_coded as substitute_regimen \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 4284 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4243,4176,4245,4246) \n ) \n )substitutereg \n on substitutereg.person_id = currentreg.person_id \n)regimen \nwhere ARV_regimen = 4678)\n','2020-06-05 09:07:37',4,'2020-11-20 12:57:31',4,0,NULL,NULL,NULL,'a4b6d688-df41-4817-a621-6be6ab32ea59'),(548,'adult_arv_1k_other_months','other duration supply of 1k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1k_other_months\n other duration supply of 1k\n \n 2020-06-05 07:08:26 UTC\n \n 2020-06-05 07:08: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 548\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4679 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded in (4243,4176,4245,4246) \n)\n','2020-06-05 09:08:26',4,'2020-06-05 09:08:46',4,0,NULL,NULL,NULL,'eec6e550-453f-4cb5-a27d-fe60c9dcfdf2'),(549,'adult_arv_1m_other_months','other duration supply of 1m','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1m_other_months\n other duration supply of 1m\n \n 2020-06-05 07:09:19 UTC\n \n 2020-06-05 07:09: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 549\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4680 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded in (4243,4176,4245,4246) \n)\n','2020-06-05 09:09:19',4,'2020-06-05 09:09:41',4,0,NULL,NULL,NULL,'7b67d262-9d16-401d-b604-d91cc253865c'),(550,'adult_arv_1n_other_months','other duration supply of 1n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1n_other_months\n other duration supply of 1n\n \n 2020-06-05 07:10:29 UTC\n \n 2020-06-16 13:34: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 550\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4681 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded in (4243,4176,4245,4246) \n)\n','2020-06-05 07:10:29',4,'2020-06-16 13:34:20',4,0,NULL,NULL,NULL,'952e2836-4856-4364-a91b-b293d5b851d6'),(551,'adult_arv_1p_other_months','other duration supply of 1p','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1p_other_months\n other duration supply of 1p\n \n 2020-06-05 07:16:58 UTC\n \n 2020-06-05 07:17: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 551\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4682 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded in (4243,4176,4245,4246) \n)\n','2020-06-05 09:16:58',4,'2020-06-05 09:17:16',4,0,NULL,NULL,NULL,'be570315-7ba8-466b-8b22-e61f30e0e4c3'),(552,'adult_arv_1q_other_months','other duration supply of 1q','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1q_other_months\n other duration supply of 1q\n \n 2020-06-05 07:17:50 UTC\n \n 2020-06-05 07: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 552\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4683 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded in (4243,4176,4245,4246) \n)\n','2020-06-05 09:17:50',4,'2020-06-05 09:18:06',4,0,NULL,NULL,NULL,'10da0e87-2ff1-4e44-9503-81b78ef95b8b'),(553,'adult_arv_other_other_months','other duration supply of other regimen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_other_other_months\n other duration supply of other regimen\n \n 2020-06-05 07:18:56 UTC\n \n 2020-06-05 07:19: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 553\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2143 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded in (4243,4176,4245,4246) \n)\n','2020-06-05 09:18:56',4,'2020-06-05 09:19:10',4,0,NULL,NULL,NULL,'6f6651ce-3b9c-46e2-9408-1af9b76331bb'),(554,'2020_Pre_ART','pre art PIR for new ART dataset','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_Pre_ART\n pre art PIR for new ART dataset\n \n 2020-06-05 07:21:23 UTC\n \n 2020-06-05 07:21: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 554\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','2020-06-05 09:21:23',4,'2020-06-05 09:21:25',4,0,NULL,NULL,NULL,'825334cf-ea81-4d70-8166-4479b7656543'),(555,'2020_Pre_ART Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_Pre_ART Data Set\n \n 2020-06-05 07:21:25 UTC\n \n 2020-08-04 16:20: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 555\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 EverF14\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 Children 0to14\n \n \n \n \n \n EverF15\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 15+yrs\n \n \n \n \n \n EverM14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n EverM15\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 15+yrs\n \n \n \n \n \n PreF14\n \n \n \n \n \n \n \n \n \n PreF15\n \n \n \n \n \n \n PreM14\n \n \n \n \n \n \n PreM15\n \n \n \n \n \n \n','2020-06-05 07:21:25',4,'2020-08-04 16:20:06',4,0,NULL,NULL,NULL,'a758fb74-1fc9-4fce-a6d8-531decf8be2a'),(557,'2020_ART_Current Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_ART_Current Data Set\n \n 2020-06-05 07:26:21 UTC\n \n 2020-09-14 13:54: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 557\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n DM_Age\n \n \n \n \n \n \n \n \n DefaultF1-\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 DefaultF10\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n DefaultF15\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n DefaultF20\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n DefaultF25\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 25to29yrs\n \n \n \n \n \n DefaultF30\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 30to34yrs\n \n \n \n \n \n DefaultF35\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 35to39yrs\n \n \n \n \n \n DefaultF40\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 40to44yrs\n \n \n \n \n \n DefaultF45\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 45to49yrs\n \n \n \n \n \n DefaultF5-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n DefaultF50\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 50+yrs\n \n \n \n \n \n DefaultF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n DefaultM1-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n DefaultM10\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n DefaultM15\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n DefaultM20\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n DefaultM25\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 25to29yrs\n \n \n \n \n \n DefaultM30\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 30to34yrs\n \n \n \n \n \n DefaultM35\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 35to39yrs\n \n \n \n \n \n DefaultM40\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 40to44yrs\n \n \n \n \n \n DefaultM45\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 45to49yrs\n \n \n \n \n \n DefaultM5-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n DefaultM50\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 50+yrs\n \n \n \n \n \n DefaultM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n DiedClient\n \n \n \n \n \n \n \n \n \n LostToFU\n \n \n \n \n \n \n \n \n \n MMD_F1-4\n \n \n \n \n \n \n \n \n \n MMD_F10-14\n \n \n \n \n \n \n MMD_F15-19\n \n \n \n \n \n \n MMD_F20-24\n \n \n \n \n \n \n MMD_F25-29\n \n \n \n \n \n \n MMD_F30-34\n \n \n \n \n \n \n MMD_F35-39\n \n \n \n \n \n \n MMD_F40-44\n \n \n \n \n \n \n MMD_F45-49\n \n \n \n \n \n \n MMD_F5-9\n \n \n \n \n \n \n MMD_F50\n \n \n \n \n \n \n MMD_F<1\n \n \n \n \n \n \n MMD_M1-4\n \n \n \n \n \n \n MMD_M10-14\n \n \n \n \n \n \n MMD_M15-19\n \n \n \n \n \n \n MMD_M20-24\n \n \n \n \n \n \n MMD_M25-29\n \n \n \n \n \n \n MMD_M30-34\n \n \n \n \n \n \n MMD_M35-39\n \n \n \n \n \n \n MMD_M40-44\n \n \n \n \n \n \n MMD_M45-49\n \n \n \n \n \n \n MMD_M5-9\n \n \n \n \n \n \n MMD_M50\n \n \n \n \n \n \n MMD_M<1\n \n \n \n \n \n \n MissedF1-4\n \n \n \n \n \n \n \n \n \n MissedF10-\n \n \n \n \n \n \n MissedF15-\n \n \n \n \n \n \n MissedF20-\n \n \n \n \n \n \n MissedF25-\n \n \n \n \n \n \n MissedF30-\n \n \n \n \n \n \n MissedF35-\n \n \n \n \n \n \n MissedF40-\n \n \n \n \n \n \n MissedF45-\n \n \n \n \n \n \n MissedF5-9\n \n \n \n \n \n \n MissedF50\n \n \n \n \n \n \n MissedF<1\n \n \n \n \n \n \n MissedM1-4\n \n \n \n \n \n \n MissedM10-\n \n \n \n \n \n \n MissedM15-\n \n \n \n \n \n \n MissedM20-\n \n \n \n \n \n \n MissedM25-\n \n \n \n \n \n \n MissedM30-\n \n \n \n \n \n \n MissedM35-\n \n \n \n \n \n \n MissedM40\n \n \n \n \n \n \n MissedM45-\n \n \n \n \n \n \n MissedM5-9\n \n \n \n \n \n \n MissedM50\n \n \n \n \n \n \n MissedM<1\n \n \n \n \n \n \n Restarted\n \n \n \n \n \n \n \n \n \n SeenFema1-\n \n \n \n \n \n \n \n \n \n SeenFema10\n \n \n \n \n \n \n SeenFema15\n \n \n \n \n \n \n SeenFema20\n \n \n \n \n \n \n SeenFema25\n \n \n \n \n \n \n SeenFema30\n \n \n \n \n \n \n SeenFema35\n \n \n \n \n \n \n SeenFema40\n \n \n \n \n \n \n SeenFema45\n \n \n \n \n \n \n SeenFema5-\n \n \n \n \n \n \n SeenFema50\n \n \n \n \n \n \n SeenFema<1\n \n \n \n \n \n \n SeenMale1-\n \n \n \n \n \n \n SeenMale10\n \n \n \n \n \n \n SeenMale15\n \n \n \n \n \n \n SeenMale20\n \n \n \n \n \n \n SeenMale25\n \n \n \n \n \n \n SeenMale30\n \n \n \n \n \n \n SeenMale35\n \n \n \n \n \n \n SeenMale40\n \n \n \n \n \n \n SeenMale45\n \n \n \n \n \n \n SeenMale5-\n \n \n \n \n \n \n SeenMale50\n \n \n \n \n \n \n SeenMale<1\n \n \n \n \n \n \n StoppedART\n \n \n \n \n \n \n \n \n \n TransferIn\n \n \n \n \n \n \n \n \n \n TransferOu\n \n \n \n \n \n \n \n \n \n newFema1-4\n \n \n \n \n \n \n \n \n \n newFema10-\n \n \n \n \n \n \n newFema15-\n \n \n \n \n \n \n newFema20-\n \n \n \n \n \n \n newFema25-\n \n \n \n \n \n \n newFema30-\n \n \n \n \n \n \n newFema35-\n \n \n \n \n \n \n newFema40-\n \n \n \n \n \n \n newFema45-\n \n \n \n \n \n \n newFema5-9\n \n \n \n \n \n \n newFema50\n \n \n \n \n \n \n newFemale1\n \n \n \n \n \n \n newMale1\n \n \n \n \n \n \n newMale1-4\n \n \n \n \n \n \n newMale10-\n \n \n \n \n \n \n newMale15-\n \n \n \n \n \n \n newMale20-\n \n \n \n \n \n \n newMale25-\n \n \n \n \n \n \n newMale30-\n \n \n \n \n \n \n newMale35-\n \n \n \n \n \n \n newMale40-\n \n \n \n \n \n \n newMale45-\n \n \n \n \n \n \n newMale5-9\n \n \n \n \n \n \n newMale50\n \n \n \n \n \n \n','2020-06-05 09:26:21',4,'2020-09-14 15:54:47',4,0,NULL,NULL,NULL,'81fbbedc-d10c-42aa-9156-e5c93cfd3741'),(558,'adult_arv_2c_1mnth','1month supply of 2c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2c_1mnth\n 1month supply of 2c\n \n 2020-06-05 08:32:14 UTC\n \n 2020-06-16 13:39: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 558\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2210 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:32:14',4,'2020-06-16 13:39:37',4,0,NULL,NULL,NULL,'4a32ce1f-8c3b-4ae7-85dc-eea24672d4d7'),(559,'adult_arv_2d_1mnth','1month supply of 2d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2d_1mnth\n 1month supply of 2d\n \n 2020-06-05 08:33:29 UTC\n \n 2020-06-16 13:40: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 559\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2203 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:33:29',4,'2020-06-16 13:40:52',4,0,NULL,NULL,NULL,'863a96d9-1dcc-4b5c-9277-5b236057bd76'),(560,'adult_arv_2e_1mnth','1month supply of 2e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2e_1mnth\n 1month supply of 2e\n \n 2020-06-05 08:34:22 UTC\n \n 2020-06-16 13: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 560\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3674 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:34:22',4,'2020-06-16 13:41:45',4,0,NULL,NULL,NULL,'8d6cded5-67a7-4121-8f10-0e99e5ee0102'),(561,'adult_arv_2f_1mnth','1month supply of 2f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2f_1mnth\n 1month supply of 2f\n \n 2020-06-05 08:35:08 UTC\n \n 2020-06-16 13: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 561\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3675 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:35:08',4,'2020-06-16 13:42:00',4,0,NULL,NULL,NULL,'04265c85-d096-469c-ac3e-6a78f938ed67'),(562,'adult_arv_2g_1mnth','1month supply of 2g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2g_1mnth\n 1month supply of 2g\n \n 2020-06-05 08:35:54 UTC\n \n 2020-06-16 13:42: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 562\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3676 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:35:54',4,'2020-06-16 13:42:18',4,0,NULL,NULL,NULL,'630e20f6-dc99-460f-a0e2-54b1eea5a00c'),(563,'adult_arv_2h_1mnth','1month supply of 2h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2h_1mnth\n 1month supply of 2h\n \n 2020-06-05 08:37:24 UTC\n \n 2020-06-16 13: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 563\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3677 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:37:24',4,'2020-06-16 13:42:37',4,0,NULL,NULL,NULL,'974cf406-f3d5-4b42-b351-5dcb94f75017'),(564,'adult_arv_2j_1mnth','1month supply of 2j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2j_1mnth\n 1month supply of 2j\n \n 2020-06-05 08:39:19 UTC\n \n 2020-06-16 13:48: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 564\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4689 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:39:19',4,'2020-06-16 13:48:26',4,0,NULL,NULL,NULL,'4d64975e-b01c-46ed-bec8-137a544b7bc7'),(565,'adult_arv_2k_1mnth','1month supply of 2k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2k_1mnth\n 1month supply of 2k\n \n 2020-06-05 08:40:07 UTC\n \n 2020-06-16 13:42: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 565\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4690 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:40:07',4,'2020-06-16 13:42:56',4,0,NULL,NULL,NULL,'3c3d19f1-dad1-4b7b-b994-975f47b7445a'),(566,'adult_arv_2l_1mnth','1month supply of 2l','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2l_1mnth\n 1month supply of 2l\n \n 2020-06-05 08:41:30 UTC\n \n 2020-06-16 13:43: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 566\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4691 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:41:30',4,'2020-06-16 13:43:15',4,0,NULL,NULL,NULL,'b22e2178-de68-4fc6-ae05-601245b6a5b2'),(567,'adult_arv_2m_1mnth','1month supply','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2m_1mnth\n 1month supply\n \n 2020-06-05 08:44:35 UTC\n \n 2020-06-16 13:43: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 567\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4692 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:44:35',4,'2020-06-16 13:43:30',4,0,NULL,NULL,NULL,'a38fa644-0c38-4463-ab26-5c926f886dc9'),(568,'adult_arv_2n_1mnth','1month supply of 2n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2n_1mnth\n 1month supply of 2n\n \n 2020-06-05 08:46:20 UTC\n \n 2020-06-16 13:43: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 568\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4693 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:46:20',4,'2020-06-16 13:43:46',4,0,NULL,NULL,NULL,'2a93bd17-c3eb-4fc4-86fc-ce5849b76bd4'),(569,'adult_arv_2o_1mnth','1month supply of 2o','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2o_1mnth\n 1month supply of 2o\n \n 2020-06-05 08:47:30 UTC\n \n 2020-06-16 13:44: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 569\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4694 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:47:30',4,'2020-06-16 13:44:03',4,0,NULL,NULL,NULL,'eb37ce3b-5110-41b8-a3f0-40f0f3b5db75'),(570,'adult_arv_2p_1mnth','1month supply of 2p','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2p_1mnth\n 1month supply of 2p\n \n 2020-06-05 08:48:45 UTC\n \n 2020-06-16 13:49: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 570\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4695 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:48:45',4,'2020-06-16 13:49:22',4,0,NULL,NULL,NULL,'9a54959a-25c3-4cd1-8382-e00379577eeb'),(571,'adult_arv_2q_1mnth','1month supply of 2q','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2q_1mnth\n 1month supply of 2q\n \n 2020-06-05 08:49:34 UTC\n \n 2020-11-20 11:31: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 571\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4849 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 10:49:34',4,'2020-11-20 13:31:18',4,0,NULL,NULL,NULL,'149baa8e-a071-41bf-99fb-97a781d12330'),(572,'Clients seen given 1 month supply 3a','1month supply of 3a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 3a\n 1month supply of 3a\n \n 2020-06-05 08:51:33 UTC\n \n 2021-07-25 15:37: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 572\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3683)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-06-05 08:51:33',4,'2021-07-25 15:37:23',4,0,NULL,NULL,NULL,'ad771405-a581-4e57-bb60-e2326ee778ca'),(573,'Clients seen given 1 month supply 3b','1month supply of 3b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 3b\n 1month supply of 3b\n \n 2020-06-05 08:52:22 UTC\n \n 2021-07-13 15:10: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 573\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3684)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-06-05 08:52:22',4,'2021-07-13 15:10:31',4,0,NULL,NULL,NULL,'8ce36691-8f7b-42ff-9638-84dc3ce7b473'),(574,'Clients seen given 1 month supply 3c','1month supply of 3c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 3c\n 1month supply of 3c\n \n 2020-06-05 08:53:22 UTC\n \n 2021-07-13 15:11: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 574\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3685)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-06-05 08:53:22',4,'2021-07-13 15:11:00',4,0,NULL,NULL,NULL,'97e72602-8099-4ead-8ed8-63c18ddc337f'),(575,'Clients seen given 1 month supply 3d','1month supply of 3d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 3d\n 1month supply of 3d\n \n 2020-06-05 08:54:01 UTC\n \n 2021-07-13 15:11: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 575\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4706)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-06-05 08:54:01',4,'2021-07-13 15:11:33',4,0,NULL,NULL,NULL,'19fff766-eb8f-41f2-8d76-8f6505bbb9b9'),(576,'Clients seen given 1 month supply 3e','1month supply of 3e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 3e\n 1month supply of 3e\n \n 2020-06-05 08:54:50 UTC\n \n 2021-07-13 15:11: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 576\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4707)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-06-05 08:54:50',4,'2021-07-13 15:11:57',4,0,NULL,NULL,NULL,'b2e90223-56f5-4e04-89e1-d9cc1fc34b17'),(577,'Clients seen given 1 month supply 3f','1month supply of 3f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 3f\n 1month supply of 3f\n \n 2020-06-05 08:58:16 UTC\n \n 2021-07-13 15: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 577\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4708)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-06-05 08:58:16',4,'2021-07-13 15:12:26',4,0,NULL,NULL,NULL,'fdc65c1d-6a93-4a2d-bfc8-19f93d762531'),(578,'Clients seen given 1 month supply 3g','1month supply of 3g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 3g\n 1month supply of 3g\n \n 2020-06-05 08:59:44 UTC\n \n 2021-07-13 15:12: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 578\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4709)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-06-05 08:59:44',4,'2021-07-13 15:12:55',4,0,NULL,NULL,NULL,'72a63ae5-4204-4f3a-803a-6ede62fee967'),(579,'Clients seen given 1 month supply 3h','1month supply of 3h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 3h\n 1month supply of 3h\n \n 2020-06-05 09:00:47 UTC\n \n 2021-07-13 15:13:35 UTC\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 endDate\n \n java.util.Date\n true\n \n \n 579\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4710)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-06-05 09:00:47',4,'2021-07-13 15:13:35',4,0,NULL,NULL,NULL,'a1042d17-e93e-407e-a91e-e6cdf2930ab6'),(580,'adult_arv_2c_3mnth','3months supply of 2c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2c_3mnth\n 3months supply of 2c\n \n 2020-06-05 09:02:19 UTC\n \n 2020-06-05 09:02: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 580\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2210 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:02:19',4,'2020-06-05 11:02:33',4,0,NULL,NULL,NULL,'d0c31b7a-ea56-4f12-a574-924391d2dcb0'),(581,'adult_arv_2d_3mnth','3months supply of 2d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2d_3mnth\n 3months supply of 2d\n \n 2020-06-05 09:03:04 UTC\n \n 2020-06-05 09:03: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 581\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2209 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:03:04',4,'2020-06-05 11:03:19',4,0,NULL,NULL,NULL,'0f6c5bd6-8635-463f-80c8-d5322e97fe54'),(582,'adult_arv_2e_3mnth','3months aupply of 2e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2e_3mnth\n 3months aupply of 2e\n \n 2020-06-05 09:03:56 UTC\n \n 2020-06-05 09:04: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 582\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2205 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:03:56',4,'2020-06-05 11:04:38',4,0,NULL,NULL,NULL,'62d0a57e-51b0-4f3e-967a-12ce18b24778'),(583,'adult_arv_2f_3mnth','3mnths supply of 2f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2f_3mnth\n 3mnths supply of 2f\n \n 2020-06-05 09:09:02 UTC\n \n 2020-06-05 09:09: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 583\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3675 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:09:02',4,'2020-06-05 11:09:21',4,0,NULL,NULL,NULL,'969c9f38-af5e-4595-af5e-346abc080fb5'),(584,'adult_arv_2g_3mnth','3months supply of 2g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2g_3mnth\n 3months supply of 2g\n \n 2020-06-05 09:15:50 UTC\n \n 2020-06-05 09:16: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 584\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3676 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:15:50',4,'2020-06-05 11:16:07',4,0,NULL,NULL,NULL,'c0193c8c-6d28-4787-990e-bb7a38eb6284'),(585,'adult_arv_2h_3mnth','3months supply of 2h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2h_3mnth\n 3months supply of 2h\n \n 2020-06-05 09:17:00 UTC\n \n 2020-06-05 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 585\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3677 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:17:00',4,'2020-06-05 11:19:06',4,0,NULL,NULL,NULL,'b675b59a-567a-45eb-bb4f-04843ed1719f'),(586,'adult_arv_2j_3mnth','3months supply of 2j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2j_3mnth\n 3months supply of 2j\n \n 2020-06-05 09:19:35 UTC\n \n 2020-06-05 09:19: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 586\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4689 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:19:35',4,'2020-06-05 11:19:53',4,0,NULL,NULL,NULL,'32aaed67-7f8c-40bc-829a-959b7dcb1bfe'),(587,'adult_arv_2k_3mnth','3months supply of 2k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2k_3mnth\n 3months supply of 2k\n \n 2020-06-05 09:21:52 UTC\n \n 2020-06-05 09:22: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 587\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4690 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:21:52',4,'2020-06-05 11:22:08',4,0,NULL,NULL,NULL,'3333bc62-d534-423c-bc79-b477f5296f51'),(588,'adult_arv_2l_3mnth','3months supply of 2l','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2l_3mnth\n 3months supply of 2l\n \n 2020-06-05 09:23:04 UTC\n \n 2020-06-05 09:23: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 588\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2201 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4691 \n)\n','2020-06-05 11:23:04',4,'2020-06-05 11:23:19',4,0,NULL,NULL,NULL,'aa37e85b-a2fb-41af-97b1-d25b86a87ad5'),(589,'adult_arv_2m_3mnth','3months supply of 2m','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2m_3mnth\n 3months supply of 2m\n \n 2020-06-05 09:23:46 UTC\n \n 2020-06-05 09:24: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 589\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4692 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:23:46',4,'2020-06-05 11:24:00',4,0,NULL,NULL,NULL,'d67a7838-10cf-4ae8-a536-38ba96c2ca9a'),(590,'adult_arv_2n_3mnth','3mnths supply of 2n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2n_3mnth\n 3mnths supply of 2n\n \n 2020-06-05 09:24:28 UTC\n \n 2020-06-05 09:24: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 590\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4693 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:24:28',4,'2020-06-05 11:24:46',4,0,NULL,NULL,NULL,'05a68334-52b7-4a39-8221-f4f3c02b26f6'),(591,'adult_arv_2o_3mnth','3mnths supply of 2o','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2o_3mnth\n 3mnths supply of 2o\n \n 2020-06-05 09:25:16 UTC\n \n 2020-06-05 09:25: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 591\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4694 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:25:16',4,'2020-06-05 11:25:40',4,0,NULL,NULL,NULL,'fe8ca75f-be0f-4047-b0a8-3836ad3c8220'),(592,'adult_arv_2p_3mnth','3months supply of 2p','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2p_3mnth\n 3months supply of 2p\n \n 2020-06-05 09:26:29 UTC\n \n 2020-06-05 09:26: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 592\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4695 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:26:29',4,'2020-06-05 11:26:46',4,0,NULL,NULL,NULL,'34c0a5a2-e192-4423-9067-6c15c57534ea'),(593,'2020_TB_Screening','new dataset TB Screening','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_TB_Screening\n new dataset TB Screening\n \n 2020-06-05 09:27:25 UTC\n \n 2020-06-05 09:27: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 593\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','2020-06-05 11:27:25',4,'2020-06-05 11:27:28',4,0,NULL,NULL,NULL,'5f5679ca-795d-434b-a3e0-354fec02f6e8'),(594,'2020_TB_Screening Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_TB_Screening Data Set\n \n 2020-06-05 09:27:28 UTC\n \n 2020-08-04 17:36: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 594\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 TBCaseAdF\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 15+yrs\n \n \n \n \n \n TBCaseAdM\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 15+yrs\n \n \n \n \n \n TBCaseChF\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n TBCaseChM\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n TBTreatAdF\n \n \n \n \n \n \n \n \n \n TBTreatAdM\n \n \n \n \n \n \n TBTreatChF\n \n \n \n \n \n \n TBTreatChM\n \n \n \n \n \n \n screen14F\n \n \n \n \n \n \n \n \n \n screen14M\n \n \n \n \n \n \n screen15+F\n \n \n \n \n \n \n screen15+M\n \n \n \n \n \n \n seen14F\n \n \n \n \n \n \n \n \n \n seen14M\n \n \n \n \n \n \n seen15+F\n \n \n \n \n \n \n seen15+M\n \n \n \n \n \n \n start14F\n \n \n \n \n \n \n start14M\n \n \n \n \n \n \n start15+F\n \n \n \n \n \n \n start15+M\n \n \n \n \n \n \n','2020-06-05 09:27:28',4,'2020-08-04 17:36:49',4,0,NULL,NULL,NULL,'4d895f5d-ede9-42b0-ae52-7e97a646c2d7'),(595,'adult_arv_2q_3mnth','3mnths supply of 2q','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2q_3mnth\n 3mnths supply of 2q\n \n 2020-06-05 09:29:55 UTC\n \n 2020-11-20 11:33: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 595\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4849 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:29:55',4,'2020-11-20 13:33:12',4,0,NULL,NULL,NULL,'5e16b0e3-6356-4963-8a44-259095ecfb88'),(596,'Clients newly initiated 4c','4c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4c\n 4c\n \n 2020-06-05 09:51:25 UTC\n \n 2021-01-27 22:08: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 596\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2202 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 09:51:25',4,'2021-01-27 22:08:31',4,0,NULL,NULL,NULL,'e9bdc7db-4154-4d56-ae30-e5e22cd2276d'),(597,'Clients newly initiated 4d','4d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4d\n 4d\n \n 2020-06-05 09:54:04 UTC\n \n 2021-01-27 22:19: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 597\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2204 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 09:54:04',4,'2021-01-27 22:19:28',4,0,NULL,NULL,NULL,'2f6f3d47-f7f2-4059-a098-e1164c572f36'),(598,'Clients newly initiated 4e','4e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4e\n 4e\n \n 2020-06-05 09:54:44 UTC\n \n 2021-01-27 22:21: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 598\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3679 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 09:54:44',4,'2021-01-27 22:21:19',4,0,NULL,NULL,NULL,'3b4b75da-e900-4fdf-8594-c25d3a20e047'),(599,'Clients newly initiated 4f','4f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4f\n 4f\n \n 2020-06-05 09:56:08 UTC\n \n 2021-01-27 22:22: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 599\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3680 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 09:56:08',4,'2021-01-27 22:22:42',4,0,NULL,NULL,NULL,'07ea75ac-aa04-47ef-aec5-5c56aaa7143e'),(600,'Clients newly initiated 4g','4g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4g\n 4g\n \n 2020-06-05 09:56:57 UTC\n \n 2021-01-27 22:24: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 600\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4684 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 09:56:57',4,'2021-01-27 22:24:27',4,0,NULL,NULL,NULL,'e0d57b65-99fd-4058-8626-143e4dff86c9'),(601,'Clients newly initiated 4h','4h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4h\n 4h\n \n 2020-06-05 09:58:19 UTC\n \n 2021-01-27 22: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 601\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4685 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 09:58:19',4,'2021-01-27 22:25:35',4,0,NULL,NULL,NULL,'d56c2ea1-4ddf-4d2d-85e3-b25806f12a50'),(602,'Clients newly initiated 4k','4k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4k\n 4k\n \n 2020-06-05 09:59:20 UTC\n \n 2021-01-27 22:29: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 602\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4687 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 09:59:20',4,'2021-01-27 22:29:03',4,0,NULL,NULL,NULL,'938aad64-3bc8-46d7-aaec-36522d65e24b'),(603,'Clients newly initiated 4L','4L','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4L\n 4L\n \n 2020-06-05 10:05:28 UTC\n \n 2021-01-27 22:30: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 603\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4688 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:05:28',4,'2021-01-27 22:30:13',4,0,NULL,NULL,NULL,'368e8627-12e2-4d50-81ce-ac338ad1c858'),(604,'Clients newly initiated 5a','5a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 5a\n 5a\n \n 2020-06-05 10:07:35 UTC\n \n 2021-01-27 22:32: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 604\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3681 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:07:35',4,'2021-01-27 22:32:44',4,0,NULL,NULL,NULL,'2dd7cbae-8054-4270-bf2a-9ec98eef1747'),(605,'Clients newly initiated 5b','5b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 5b\n 5b\n \n 2020-06-05 10:09:31 UTC\n \n 2021-01-27 22:35: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 605\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3682 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:09:31',4,'2021-01-27 22:35:45',4,0,NULL,NULL,NULL,'d8c18842-91aa-4102-a19a-1f48780c4daa'),(606,'Clients newly initiated 5c','5c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 5c\n 5c\n \n 2020-06-05 10:11:40 UTC\n \n 2021-01-27 22:37: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 606\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4696 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:11:40',4,'2021-01-27 22:37:24',4,0,NULL,NULL,NULL,'655a6791-e753-405e-831f-c527d63386ab'),(607,'Clients newly initiated 5d','5d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 5d\n 5d\n \n 2020-06-05 10:12:25 UTC\n \n 2021-01-27 22:39: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 607\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4697 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:12:25',4,'2021-01-27 22:39:19',4,0,NULL,NULL,NULL,'c7e733d9-f5ec-4799-bb83-0f8e38f9a5e1'),(608,'Clients newly initiated 5e','5e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 5e\n 5e\n \n 2020-06-05 10:13:16 UTC\n \n 2021-01-27 22:40: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 608\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4698 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:13:16',4,'2021-01-27 22:40:36',4,0,NULL,NULL,NULL,'09ce91e0-7242-41fa-b68f-551daabefd2e'),(609,'Clients newly initiated 5g','5g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 5g\n 5g\n \n 2020-06-05 10:15:17 UTC\n \n 2021-01-27 22:44: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 609\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4700 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:15:17',4,'2021-01-27 22:44:28',4,0,NULL,NULL,NULL,'c529cc30-cff7-4a9b-8ca6-9bccd505139e'),(610,'Clients newly initiated 5h','5h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 5h\n 5h\n \n 2020-06-05 10:15:50 UTC\n \n 2021-01-27 22:46: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 610\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4701 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:15:50',4,'2021-01-27 22:46:38',4,0,NULL,NULL,NULL,'e316ba5b-a507-493a-8183-3b48bdea3c65'),(611,'Clients newly initiated 6a','6a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 6a\n 6a\n \n 2020-06-05 10:16:53 UTC\n \n 2021-01-27 22:49: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 611\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3686 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:16:53',4,'2021-01-27 22:49:29',4,0,NULL,NULL,NULL,'7cd2486f-34f5-4a78-a016-70512f5b4830'),(612,'Clients newly initiated 6b','6b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 6b\n 6b\n \n 2020-06-05 10:18:54 UTC\n \n 2021-01-27 22:56: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 612\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3687 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:18:54',4,'2021-01-27 22:56:39',4,0,NULL,NULL,NULL,'4b8c4474-fcb5-43e5-9eb8-75695ee52205'),(613,'Clients newly initiated 6c','6c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 6c\n 6c\n \n 2020-06-05 10:19:34 UTC\n \n 2021-01-27 22: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 613\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4702 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:19:34',4,'2021-01-27 22:58:59',4,0,NULL,NULL,NULL,'f3536aac-02a4-42ec-ab92-e43da022e09b'),(614,'2020_COTRIMOX PROPHYLAXIS/DAPSONE','new dataset clients who received CTX','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_COTRIMOX PROPHYLAXIS/DAPSONE\n new dataset clients who received CTX\n \n 2020-06-05 10:20:14 UTC\n \n 2020-06-05 10:20: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 614\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','2020-06-05 12:20:14',4,'2020-06-05 12:20:17',4,0,NULL,NULL,NULL,'8dc80efd-3c35-4d1a-ad4e-5f9f26caeaf5'),(615,'2020_COTRIMOX PROPHYLAXIS/DAPSONE Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_COTRIMOX PROPHYLAXIS/DAPSONE Data Set\n \n 2020-06-05 10:20:17 UTC\n \n 2020-06-06 18:16: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 615\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 CTX_F1-4\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 CTX_F5-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05yrsto14yrs\n \n \n \n \n \n CTX_F<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n CTX_FAdult\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Adults\n \n \n \n \n \n CTX_M1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n CTX_M5-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05yrsto14yrs\n \n \n \n \n \n CTX_M<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n CTX_MAdult\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Adults\n \n \n \n \n \n','2020-06-05 12:20:17',4,'2020-06-06 20:16:22',4,0,NULL,NULL,NULL,'9661c0bc-601a-4b16-b0de-4d891c2d93bc'),(616,'Clients newly initiated 6d','6d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 6d\n 6d\n \n 2020-06-05 10:20:21 UTC\n \n 2021-01-27 23: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 616\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4703 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:20:21',4,'2021-01-27 23:00:12',4,0,NULL,NULL,NULL,'26bd109c-b9bf-41cd-8b76-027713846950'),(617,'Clients newly initiated 6e','6e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 6e\n 6e\n \n 2020-06-05 10:21:00 UTC\n \n 2021-01-27 23: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 617\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4704 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:21:00',4,'2021-01-27 23:03:14',4,0,NULL,NULL,NULL,'9dfe2b8b-dc4c-4708-8672-977b5de9526d'),(618,'Clients newly initiated 6f','6f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 6f\n 6f\n \n 2020-06-05 10:22:22 UTC\n \n 2021-01-27 23:04: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 618\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4705 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:22:22',4,'2021-01-27 23:04:14',4,0,NULL,NULL,NULL,'10f50f0b-9282-4d68-9e57-13c17e37b411'),(619,'adult_arv_1c_1mnth','1c 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1c_1mnth\n 1c 1mnth\n \n 2020-06-05 10:42:17 UTC\n \n 2021-01-27 15:47: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 619\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 10:42:17',4,'2021-01-27 15:47:12',4,0,NULL,NULL,NULL,'4d8b2d8b-a165-42ba-abdb-2d881d7cdd0c'),(621,'Clients given CTX in the month','ctx','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given CTX in the month\n ctx\n \n 2020-06-05 10:51:40 UTC\n \n 2020-06-05 10:52: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 621\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand obs_datetime BETWEEN :startDate AND :endDate \nand concept_id = 3728 and value_numeric > 1\n','2020-06-05 12:51:40',4,'2020-06-05 12:52:11',4,0,NULL,NULL,NULL,'afa0260d-641b-45bd-a341-7582b02f70a6'),(622,'adult_arv_1d_1mnth','1d 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1d_1mnth\n 1d 1mnth\n \n 2020-06-05 10:51:52 UTC\n \n 2021-01-27 15:58: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 622\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 10:51:52',4,'2021-01-27 15:58:19',4,0,NULL,NULL,NULL,'00a20283-36e6-43cc-99c3-a9555937e320'),(623,'adult_arv_1e_1mnth','1e 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1e_1mnth\n 1e 1mnth\n \n 2020-06-05 10:54:44 UTC\n \n 2021-01-27 16:12: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 623\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 10:54:44',4,'2021-01-27 16:12:51',4,0,NULL,NULL,NULL,'b693cd81-554d-4b98-ab19-547ef5d1316d'),(624,'adult_arv_1f_1mnth','1f 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1f_1mnth\n 1f 1mnth\n \n 2020-06-05 11:02:36 UTC\n \n 2020-06-05 11:03: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 624\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:02:36',4,'2020-06-05 13:03:17',4,0,NULL,NULL,NULL,'c1745a07-d769-478c-b703-9e00ef10c3fc'),(625,'Plumpy Nut given in the month','RUFT','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Plumpy Nut given in the month\n RUFT\n \n 2020-06-05 11:02:38 UTC\n \n 2020-06-05 11:02: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 625\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand obs_datetime BETWEEN :startDate AND :endDate \nand concept_id = 4167 and value_coded = 4163\n','2020-06-05 13:02:38',4,'2020-06-05 13:02:51',4,0,NULL,NULL,NULL,'085fe744-3c4e-4d96-9621-af1ffeda1e8d'),(626,'F100 given in the month','F100','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n F100 given in the month\n F100\n \n 2020-06-05 11:03:21 UTC\n \n 2020-06-05 11:03: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 626\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand obs_datetime BETWEEN :startDate AND :endDate \nand concept_id = 4167 and value_coded = 4164\n','2020-06-05 13:03:21',4,'2020-06-05 13:03:34',4,0,NULL,NULL,NULL,'1a858146-5ad0-4914-90c6-78770ebc7045'),(627,'F75 given in the month','F75','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n F75 given in the month\n F75\n \n 2020-06-05 11:04:35 UTC\n \n 2020-06-05 11:04: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 627\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand obs_datetime BETWEEN :startDate AND :endDate \nand concept_id = 4167 and value_coded = 4165\n','2020-06-05 13:04:35',4,'2020-06-05 13:04:50',4,0,NULL,NULL,NULL,'a1c3f512-58d0-4b3c-ba09-22f38d76850e'),(628,'adult_arv_1g_1mnth','1g 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1g_1mnth\n 1g 1mnth\n \n 2020-06-05 11:04:39 UTC\n \n 2021-01-27 16:24: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 628\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:04:39',4,'2021-01-27 16:24:35',4,0,NULL,NULL,NULL,'6133c572-3574-4a36-a383-8ba8f154ae4b'),(629,'Other Nutritional Supplement given in the month','other supplement','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Other Nutritional Supplement given in the month\n other supplement\n \n 2020-06-05 11:06:00 UTC\n \n 2020-06-05 11: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 629\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand obs_datetime BETWEEN :startDate AND :endDate \nand concept_id = 4167 and value_coded = 4166\n','2020-06-05 13:06:00',4,'2020-06-05 13:06:13',4,0,NULL,NULL,NULL,'5dcaf597-94b6-40d7-9967-8f145c4c1a54'),(630,'adult_arv_1h_1mnth','1h 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1h_1mnth\n 1h 1mnth\n \n 2020-06-05 11:06:29 UTC\n \n 2021-01-27 16:39: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 630\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:06:29',4,'2021-01-27 16:39:22',4,0,NULL,NULL,NULL,'b36e2da3-c211-4c2d-a01f-4fa0a0fe1fd8'),(631,'adult_arv_1j_1mnth','1j 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1j_1mnth\n 1j 1mnth\n \n 2020-06-05 11:11:22 UTC\n \n 2021-01-27 16: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 631\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:11:22',4,'2021-01-27 16:53:30',4,0,NULL,NULL,NULL,'9560bddf-1def-45f3-8606-ce4adbbfcc19'),(632,'adult_arv_1k_1mnth','1k 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1k_1mnth\n 1k 1mnth\n \n 2020-06-05 11:12:57 UTC\n \n 2021-01-27 16:59: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 632\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:12:57',4,'2021-01-27 16:59:54',4,0,NULL,NULL,NULL,'44fcfb57-e804-4f3e-a7f3-bc488400c481'),(633,'adult_arv_1m_1mnth','1m 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1m_1mnth\n 1m 1mnth\n \n 2020-06-05 11:14:18 UTC\n \n 2021-01-27 17:12: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 633\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:14:18',4,'2021-01-27 17:12:50',4,0,NULL,NULL,NULL,'6dc933e8-a8d7-4b43-89b8-90edc570311a'),(634,'adult_arv_1n_1mnth','1n 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1n_1mnth\n 1n 1mnth\n \n 2020-06-05 11:16:41 UTC\n \n 2021-01-27 17:29: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 634\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:16:41',4,'2021-01-27 17:29:59',4,0,NULL,NULL,NULL,'cb2ca745-f914-4258-aad0-5b57ea870dbd'),(635,'adult_arv_1p_1mnth','1p 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1p_1mnth\n 1p 1mnth\n \n 2020-06-05 11:18:07 UTC\n \n 2021-01-27 17:44: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 635\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:18:07',4,'2021-01-27 17:44:00',4,0,NULL,NULL,NULL,'15aedfaf-51f7-4d96-b706-b3a3280c560a'),(636,'adult_arv_1q_1mnth','1q 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1q_1mnth\n 1q 1mnth\n \n 2020-06-05 11:19:15 UTC\n \n 2021-01-27 17:58: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 636\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:19:15',4,'2021-01-27 17:58:21',4,0,NULL,NULL,NULL,'31689512-e2e3-4401-ad27-ea802bdc3617'),(637,'adult_arv_other_1mnth','other 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_other_1mnth\n other 1mnth\n \n 2020-06-05 11:21:51 UTC\n \n 2021-07-13 11: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 637\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:21:51',4,'2021-07-13 11:05:33',4,0,NULL,NULL,NULL,'449d0ce8-0a40-4591-a309-040dfb083198'),(638,'adult_arv_1c_3mnth','1c 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1c_3mnth\n 1c 3mnths\n \n 2020-06-05 11:24:27 UTC\n \n 2021-01-27 15:49: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 638\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:24:27',4,'2021-01-27 15:49:31',4,0,NULL,NULL,NULL,'2c077d8b-0aa7-401d-aba3-788473928468'),(639,'adult_arv_1d_3mnths','1d 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1d_3mnths\n 1d 3mnths\n \n 2020-06-05 11:25:44 UTC\n \n 2021-01-27 16:00: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 639\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:25:44',4,'2021-01-27 16:00:17',4,0,NULL,NULL,NULL,'e39e1c56-fece-4095-a279-da8ae718544f'),(640,'adult_arv_1e_3mnths','1e 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1e_3mnths\n 1e 3mnths\n \n 2020-06-05 11:27:12 UTC\n \n 2021-01-27 16:16: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 640\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:27:12',4,'2021-01-27 16:16:45',4,0,NULL,NULL,NULL,'6068ee9b-96b7-4c60-ad99-59f129fb2a86'),(641,'adult_arv_1f_3mnths','1f 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1f_3mnths\n 1f 3mnths\n \n 2020-06-05 11:28:37 UTC\n \n 2020-06-05 11:29: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 641\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:28:37',4,'2020-06-05 13:29:15',4,0,NULL,NULL,NULL,'66122df9-8b00-44eb-9895-faabe0421c6c'),(642,'adult_arv_1g_3mnths','1g 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1g_3mnths\n 1g 3mnths\n \n 2020-06-05 11:29:54 UTC\n \n 2021-01-27 16:32: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 642\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:29:54',4,'2021-01-27 16:32:52',4,0,NULL,NULL,NULL,'2e325001-abd4-4c5a-82b9-0ac9886ecbb6'),(643,'adult_arv_1h_3mnths','1h 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1h_3mnths\n 1h 3mnths\n \n 2020-06-05 11:30:54 UTC\n \n 2021-01-27 16:42: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 643\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:30:54',4,'2021-01-27 16:42:06',4,0,NULL,NULL,NULL,'c15f9357-fba2-46f7-96a1-44b25379ccea'),(644,'adult_arv_1j_3mnths','1j 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1j_3mnths\n 1j 3mnths\n \n 2020-06-05 11:32:13 UTC\n \n 2021-01-27 16:55: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 644\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:32:13',4,'2021-01-27 16:55:38',4,0,NULL,NULL,NULL,'e1b0c0ec-23b6-44c7-b80a-851b276f6238'),(645,'adult_arv_1k_3mnths','1k 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1k_3mnths\n 1k 3mnths\n \n 2020-06-05 11:35:55 UTC\n \n 2021-01-27 17: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 645\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:35:55',4,'2021-01-27 17:05:10',4,0,NULL,NULL,NULL,'2e6cd3c8-b48e-4e64-ac85-11c34fdeb49c'),(646,'adult_arv_1m_3mnths','1m 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1m_3mnths\n 1m 3mnths\n \n 2020-06-05 11:37:06 UTC\n \n 2021-01-27 17:14: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 646\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:37:06',4,'2021-01-27 17:14:41',4,0,NULL,NULL,NULL,'ac70448a-01bd-4e80-b1b4-9dffa36380a0'),(647,'adult_arv_1n_3mnths','1n 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1n_3mnths\n 1n 3mnths\n \n 2020-06-05 11:38:09 UTC\n \n 2021-01-27 17:34: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 647\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:38:09',4,'2021-01-27 17:34:59',4,0,NULL,NULL,NULL,'15d01fbf-abf1-4394-9da3-6d2a2b8f02f6'),(648,'adult_arv_1p_3mnths','1p 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1p_3mnths\n 1p 3mnths\n \n 2020-06-05 11:39:05 UTC\n \n 2021-01-27 17:54: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 648\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:39:05',4,'2021-01-27 17:54:50',4,0,NULL,NULL,NULL,'222eaf25-8e7a-4d38-bca4-41642991fe3d'),(649,'adult_arv_1q_3mnths','1q 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1q_3mnths\n 1q 3mnths\n \n 2020-06-05 11:40:02 UTC\n \n 2021-01-27 17: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 649\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:40:02',4,'2021-01-27 17:53:15',4,0,NULL,NULL,NULL,'f6d560ce-615d-4607-a3d0-8ae3435535fe'),(650,'adult_arv_other_3mnths','other 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_other_3mnths\n other 3mnths\n \n 2020-06-05 11:41:25 UTC\n \n 2021-02-04 09:03: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 650\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:41:25',4,'2021-02-04 09:03:37',4,0,NULL,NULL,NULL,'6ab6f0c1-401a-4a74-842f-c97983880745'),(651,'adult_arv_1c_6mnths','1c 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1c_6mnths\n 1c 6mnths\n \n 2020-06-05 11:43:07 UTC\n \n 2021-01-27 15:53: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 651\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:43:07',4,'2021-01-27 15:53:25',4,0,NULL,NULL,NULL,'4b1fc9fe-27bd-4473-b7dd-3f756a47ccb7'),(652,'adult_arv_1d_6mnths','1d 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1d_6mnths\n 1d 6mnths\n \n 2020-06-05 11:44:21 UTC\n \n 2021-01-27 16:08: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 652\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:44:21',4,'2021-01-27 16:08:01',4,0,NULL,NULL,NULL,'eab3ea99-52e0-4ea9-83f3-6711754e40e1'),(653,'adult_arv_1e_6mnths','1e 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1e_6mnths\n 1e 6mnths\n \n 2020-06-05 11:45:53 UTC\n \n 2021-01-27 16:19: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 653\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:45:53',4,'2021-01-27 16:19:28',4,0,NULL,NULL,NULL,'a7fd11c7-b7e0-43ea-b6aa-6c51ec395bcb'),(654,'adult_arv_1f_6mnths','1f 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1f_6mnths\n 1f 6mnths\n \n 2020-06-05 11:47:04 UTC\n \n 2020-06-05 11:47: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 654\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:47:04',4,'2020-06-05 13:47:39',4,0,NULL,NULL,NULL,'1f821fff-33b0-42b0-b62c-430af9d77512'),(655,'adult_arv_1g_6mnths','1g 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1g_6mnths\n 1g 6mnths\n \n 2020-06-05 11:48:04 UTC\n \n 2021-01-27 16:34: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 655\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:48:04',4,'2021-01-27 16:34:52',4,0,NULL,NULL,NULL,'96765b0d-eef0-4990-9602-d27fb6627270'),(656,'adult_arv_1h_6mnths','1h 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1h_6mnths\n 1h 6mnths\n \n 2020-06-05 11:49:10 UTC\n \n 2021-01-27 16:44: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 656\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:49:10',4,'2021-01-27 16:44:47',4,0,NULL,NULL,NULL,'bd0a9a38-fcfc-4dd7-89bd-3d3901b6f37f'),(657,'adult_arv_1j_6mnths','1j 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1j_6mnths\n 1j 6mnths\n \n 2020-06-05 11:51:11 UTC\n \n 2021-01-27 16:57: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 657\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:51:11',4,'2021-01-27 16:57:42',4,0,NULL,NULL,NULL,'f1d1b1e3-7805-49f6-b6e1-3e51ee5ca3c1'),(658,'adult_arv_1k_6mnths','1k 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1k_6mnths\n 1k 6mnths\n \n 2020-06-05 11:52:20 UTC\n \n 2021-01-27 17:07: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 658\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:52:20',4,'2021-01-27 17:07:04',4,0,NULL,NULL,NULL,'508ebf4a-5097-447f-a087-b722c8784233'),(659,'adult_arv_1m_6mnths','1m 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1m_6mnths\n 1m 6mnths\n \n 2020-06-05 11:53:19 UTC\n \n 2021-01-27 17:17: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 659\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:53:19',4,'2021-01-27 17:17:08',4,0,NULL,NULL,NULL,'08b21870-a277-4cf5-83da-3802031cd02d'),(660,'adult_arv_1n_6mnths','1n 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1n_6mnths\n 1n 6mnths\n \n 2020-06-05 11:55:16 UTC\n \n 2021-01-27 17:38: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 660\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:55:16',4,'2021-01-27 17:38:14',4,0,NULL,NULL,NULL,'078738ed-db38-4f25-9963-74e150af6157'),(661,'adult_arv_1p_6mnths','1p 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1p_6mnths\n 1p 6mnths\n \n 2020-06-05 11:56:46 UTC\n \n 2021-01-27 17:36: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 661\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:56:46',4,'2021-01-27 17:36:45',4,0,NULL,NULL,NULL,'a2dcd6db-39bc-469e-ac03-8bfedec4c18f'),(662,'adult_arv_1q_6mnths','1q 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1q_6mnths\n 1q 6mnths\n \n 2020-06-05 11:58:12 UTC\n \n 2021-01-27 18:00: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 662\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:58:12',4,'2021-01-27 18:00:44',4,0,NULL,NULL,NULL,'71007fca-4c23-43ab-81db-9090baa8fb01'),(663,'adult_arv_other_6mnths','other 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_other_6mnths\n other 6mnths\n \n 2020-06-05 11:59:58 UTC\n \n 2021-02-04 09:05: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 663\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:59:58',4,'2021-02-04 09:05:16',4,0,NULL,NULL,NULL,'24d02723-dc41-4afa-8f45-6da91778130a'),(664,'adult_arv_1c_other_mnths','1c other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1c_other_mnths\n 1c other supply\n \n 2020-06-05 12:03:30 UTC\n \n 2021-01-27 15:56: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 664\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:03:30',4,'2021-01-27 15:56:35',4,0,NULL,NULL,NULL,'fc0771aa-32dc-43da-b4eb-283519fedfd1'),(665,'adult_arv_1d_other_mnths','1d other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1d_other_mnths\n 1d other supply\n \n 2020-06-05 12:07:38 UTC\n \n 2021-01-27 16: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 665\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:07:38',4,'2021-01-27 16:10:12',4,0,NULL,NULL,NULL,'99e2601c-ddcc-42be-a3af-b659bbfdd9ea'),(666,'adult_arv_1e_other_mnths','1e other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1e_other_mnths\n 1e other supply\n \n 2020-06-05 12:09:09 UTC\n \n 2021-01-27 16:20: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 666\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:09:09',4,'2021-01-27 16:20:56',4,0,NULL,NULL,NULL,'5ee5c1d7-9ccf-44f3-b620-c849f9e502cb'),(667,'adult_arv_1f_other_mnths','1f other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1f_other_mnths\n 1f other supply\n \n 2020-06-05 12:10:11 UTC\n \n 2020-06-05 12:10: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 667\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 14:10:11',4,'2020-06-05 14:10:46',4,0,NULL,NULL,NULL,'c54c9e70-972e-475e-accd-d590158089aa'),(668,'adult_arv_1g_other_mnths','1g other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1g_other_mnths\n 1g other supply\n \n 2020-06-05 12:11:10 UTC\n \n 2020-06-05 12:11: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 668\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 14:11:10',4,'2020-06-05 14:11:48',4,0,NULL,NULL,NULL,'6f497b96-793f-444c-b599-b8c84802c8ce'),(669,'adult_arv_1h_other_mnths','1h other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1h_other_mnths\n 1h other supply\n \n 2020-06-05 12:12:15 UTC\n \n 2021-01-27 16:50: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 669\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:12:15',4,'2021-01-27 16:50:25',4,0,NULL,NULL,NULL,'6d91768d-95ad-42ff-a2e8-b994e7af2f3a'),(670,'adult_arv_1j_other_mnths','1j other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1j_other_mnths\n 1j other supply\n \n 2020-06-05 12:14:44 UTC\n \n 2020-06-05 12:15: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 670\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 14:14:44',4,'2020-06-05 14:15:18',4,0,NULL,NULL,NULL,'6176f910-0ee7-4ba9-997e-ce7585f83ae8'),(671,'adult_arv_1k_other_mnths','1k other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1k_other_mnths\n 1k other supply\n \n 2020-06-05 12:15:41 UTC\n \n 2021-01-27 17:08: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 671\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:15:41',4,'2021-01-27 17:08:52',4,0,NULL,NULL,NULL,'6e5cbb5d-f451-47ea-a2fd-9bff1f28f555'),(672,'Missed or defaulted under 28days','missed or defaulted < 28','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Missed or defaulted under 28days\n missed or defaulted < 28\n \n 2020-06-05 12:16:25 UTC\n \n 2024-02-06 09: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 672\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \n and l.location_id = :location or l.parent_location = :location \n -- PATIENTS WHO HAVE NOT SHOWED UP FOR THEIR APPOINTMENT FOR UP TO 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 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) > 0 \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 and os.voided = 0 \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 \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 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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n ) \n \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' \n\n','2020-06-05 17:46:25',4,'2024-02-06 14:50:18',4,0,NULL,NULL,NULL,'a7064d93-cb9d-44f7-b7cb-f0d38313fdb3'),(673,'adult_arv_1m_other_mnths','1m other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1m_other_mnths\n 1m other supply\n \n 2020-06-05 12:16:47 UTC\n \n 2021-01-27 17:18: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 673\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:16:47',4,'2021-01-27 17:18:26',4,0,NULL,NULL,NULL,'9ebb3d1c-52e8-40e7-abc2-871abfdd6ffa'),(674,'adult_arv_1n_other_mnths','1n other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1n_other_mnths\n 1n other supply\n \n 2020-06-05 12:17:46 UTC\n \n 2021-01-27 17: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 674\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:17:46',4,'2021-01-27 17:41:01',4,0,NULL,NULL,NULL,'b829a556-e0e5-4856-8800-ea2560894f62'),(675,'adult_arv_1p_other_mnths','1p other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1p_other_mnths\n 1p other supply\n \n 2020-06-05 12:20:31 UTC\n \n 2021-01-27 17:49: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 675\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:20:31',4,'2021-01-27 17:49:53',4,0,NULL,NULL,NULL,'6843123f-248a-4232-9008-a51ffdc43c5b'),(676,'adult_arv_1q_other_mnths','1q other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1q_other_mnths\n 1q other supply\n \n 2020-06-05 12:21:42 UTC\n \n 2021-01-27 18: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 676\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:21:42',4,'2021-01-27 18:07:21',4,0,NULL,NULL,NULL,'762d08de-74a3-40fe-9240-1fc904fcb69e'),(677,'Missed or defaulted between 29 and 89 days','missed >29\r\nmissed < 90','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Missed or defaulted between 29 and 89 days\n missed >29 \nmissed < 90\n \n 2020-06-05 12:22:30 UTC\n \n 2024-02-15 09: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 endDateAS\n \n java.util.Date\n true\n \n \n 677\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \n and l.location_id = :location or l.parent_location = :location \n -- PATIENTS WHO HAVE NOT SHOWED UP FOR THEIR APPOINTMENT FOR 4 WEEKS to 3 MONTHS (i.e. 29 to 89 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 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 and DATEDIFF(CAST(:endDate AS DATE),latest_follow_up) <= 89 \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 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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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' \n \n','2020-06-05 17:52:30',4,'2024-02-15 14:42:20',4,0,NULL,NULL,NULL,'5be87aeb-a57c-4a02-83e7-93d560d49fbb'),(678,'adult_arv_other_other_mnths','other other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_other_other_mnths\n other other supply\n \n 2020-06-05 12:23:07 UTC\n \n 2021-02-04 09:06: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 678\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:23:07',4,'2021-02-04 09:06:31',4,0,NULL,NULL,NULL,'c53c49b3-0557-4f1a-9006-1a88e542519d'),(679,'adult_arv_2c_1mnth','2c 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2c_1mnth\n 2c 1mnth\n \n 2020-06-05 12:36:06 UTC\n \n 2021-07-13 14:26: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 679\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:36:06',4,'2021-07-13 14:26:45',4,0,NULL,NULL,NULL,'69830812-bc46-428a-b10e-43a31a982e02'),(680,'LTFU this month','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 LTFU this month\n lost to follow up\n \n 2020-06-05 12:37:18 UTC\n \n 2020-06-05 12:38: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 680\n select distinct o.person_id \nFROM obs o \nINNER JOIN patient ON o.person_id = patient.patient_id \nand o.concept_id = 3752 \nand o.value_datetime in \n ( \n select latestFU from \n ( \n select distinct os.person_id, max(os.value_datetime) AS latestFU, datediff(CAST(:endDate AS DATE), max(value_datetime)) AS \n Num_Days \n from obs os \n inner join person_name pn on os.person_id = pn.person_id \n inner join patient p on pn.person_id = p.patient_id and pn.voided = 0 \n inner join person ps on ps.person_id = p.patient_id and ps.voided = 0 \n where os.concept_id = 3752 \n and obs_datetime <= :endDate \n group by os.person_id \n having Num_Days > 7 \n and Num_Days < 30 \n ) as lost \n ) \nand o.person_id in \n ( \n select person_id from \n ( \n select distinct os.person_id, max(os.value_datetime) AS latestFU, datediff(CAST(:endDate AS DATE), \n max(value_datetime)) AS Num_Days \n from obs os \n inner join person_name pn on os.person_id = pn.person_id \n inner join patient p on pn.person_id = p.patient_id and pn.voided = 0 \n inner join person ps on ps.person_id = p.patient_id and ps.voided = 0 \n where os.concept_id = 3752 \n and obs_datetime <= :endDate \n group by os.person_id \n having Num_Days > 90 \n ) as lost \n ) \n \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 ) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND o.person_id not in ( \n select person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n;\n','2020-06-05 14:37:18',4,'2020-06-05 14:38:18',4,0,NULL,NULL,NULL,'f5c2691c-0977-4a4d-957e-2cf973e37bb7'),(681,'adult_arv_2d_1mnth','2d 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2d_1mnth\n 2d 1mnth\n \n 2020-06-05 12:37:55 UTC\n \n 2021-07-13 14:30: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 681\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:37:55',4,'2021-07-13 14:30:11',4,0,NULL,NULL,NULL,'456f6967-04cc-4c2a-8e50-7c99e799eb29'),(682,'adult_arv_2e_1mnth','2e 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2e_1mnth\n 2e 1mnth\n \n 2020-06-05 12:39:33 UTC\n \n 2021-07-13 14:30: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 682\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:39:33',4,'2021-07-13 14:30:44',4,0,NULL,NULL,NULL,'e5b6e482-9ccb-411c-bdf4-8dc43d421947'),(683,'adult_arv_2f_1mnth','2f 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2f_1mnth\n 2f 1mnth\n \n 2020-06-05 12:40:45 UTC\n \n 2021-07-13 14:34: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 683\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:40:45',4,'2021-07-13 14:34:37',4,0,NULL,NULL,NULL,'11aa9360-825c-4aac-ab2a-65d21642765e'),(684,'adult_arv_2g_1mnth','2g 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2g_1mnth\n 2g 1mnth\n \n 2020-06-05 12:41:52 UTC\n \n 2021-07-13 14:35: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 684\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:41:52',4,'2021-07-13 14:35:21',4,0,NULL,NULL,NULL,'b55997df-2560-4087-89ad-f80379b46dd4'),(685,'adult_arv_2h_1mnth','2h 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2h_1mnth\n 2h 1mnth\n \n 2020-06-05 12:43:08 UTC\n \n 2021-07-13 14:36: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 685\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:43:08',4,'2021-07-13 14:36:13',4,0,NULL,NULL,NULL,'4420cacb-9f9e-46ca-b86d-6d03e30a6f3e'),(686,'adult_arv_2j_1mnth','2j 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2j_1mnth\n 2j 1mnth\n \n 2020-06-05 12:44:01 UTC\n \n 2021-07-13 14:37: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 686\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:44:01',4,'2021-07-13 14:37:45',4,0,NULL,NULL,NULL,'e0941c5d-4a20-400b-a0db-862be83470e1'),(687,'adult_arv_2k_1mnth','2k 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2k_1mnth\n 2k 1mnth\n \n 2020-06-05 12:45:06 UTC\n \n 2021-07-13 14:39: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 687\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:45:06',4,'2021-07-13 14:39:23',4,0,NULL,NULL,NULL,'171a878c-c036-4486-a58d-798bc80c7447'),(688,'adult_arv_2l_1mnth','2l 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2l_1mnth\n 2l 1mnth\n \n 2020-06-05 12:46:11 UTC\n \n 2021-07-13 14: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 688\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:46:11',4,'2021-07-13 14:39:38',4,0,NULL,NULL,NULL,'ae5dd3df-007d-4ef2-bcdb-0ef68ff8bc7a'),(689,'adult_arv_2m_1mnth','2m 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2m_1mnth\n 2m 1mnth\n \n 2020-06-05 12:47:05 UTC\n \n 2021-07-13 14: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 689\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:47:05',4,'2021-07-13 14:41:45',4,0,NULL,NULL,NULL,'041a095c-5497-447e-9387-97b4d34df6ab'),(690,'adult_arv_2n_1mnth','2n 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2n_1mnth\n 2n 1mnth\n \n 2020-06-05 12:48:07 UTC\n \n 2021-07-13 14:41: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 690\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:48:07',4,'2021-07-13 14:41:59',4,0,NULL,NULL,NULL,'d64e6398-89a2-4612-985f-dc20dafa92b5'),(691,'adult_arv_2o_1mnth','2o 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2o_1mnth\n 2o 1mnth\n \n 2020-06-05 12:49:21 UTC\n \n 2021-07-13 14:45: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 691\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:49:21',4,'2021-07-13 14:45:11',4,0,NULL,NULL,NULL,'e5455427-d2fd-4398-88d8-372654f69bf7'),(692,'adult_arv_2p_1mnth','2p 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2p_1mnth\n 2p 1mnth\n \n 2020-06-05 12:50:20 UTC\n \n 2021-07-13 14:44: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 692\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:50:20',4,'2021-07-13 14:44:58',4,0,NULL,NULL,NULL,'f299f60d-7b3b-471e-b575-684c94c9ee57'),(693,'adult_arv_2q_1mnth','2q 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2q_1mnth\n 2q 1mnth\n \n 2020-06-05 12:51:42 UTC\n \n 2021-07-13 14:48: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 693\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:51:42',4,'2021-07-13 14:48:08',4,0,NULL,NULL,NULL,'be23c602-cbb1-43ac-b3c8-4c508cc65d66'),(694,'adult_arv_2c_3mnth','2c 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2c_3mnth\n 2c 3mnths\n \n 2020-06-05 12:56:13 UTC\n \n 2021-07-12 09:53: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 694\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:56:13',4,'2021-07-12 09:53:59',4,0,NULL,NULL,NULL,'04215a53-92bb-448c-bc0c-bdf13968fc4a'),(695,'adult_arv_2d_3mnths','2d 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2d_3mnths\n 2d 3mnths\n \n 2020-06-05 12:57:46 UTC\n \n 2020-07-26 12:39: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 695\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:57:46',4,'2020-07-26 12:39:30',4,0,NULL,NULL,NULL,'c9657610-a606-46db-8f55-24ded88ddf65'),(696,'Stopped ART this month','stopped ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Stopped ART this month\n stopped ART\n \n 2020-06-05 12:59:50 UTC\n \n 2020-06-05 13:00: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 696\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n where (o.location_id =:location or parent_location =:location) \n AND o.voided = 0 \n and concept_id = 2300 \n AND obs_datetime between :startDate AND :endDate\n','2020-06-05 14:59:50',4,'2020-06-05 15:00:33',4,0,NULL,NULL,NULL,'90747232-9c64-460b-b297-556853c19d27'),(697,'adult_arv_2e_3mnths','2e 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2e_3mnths\n 2e 3mnths\n \n 2020-06-05 13:02:16 UTC\n \n 2020-07-26 12:41: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 697\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:02:16',4,'2020-07-26 12:41:25',4,0,NULL,NULL,NULL,'10f3e3f4-f73e-4d8d-8024-108020886525'),(698,'adult_arv_2f_3mnths','2f 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2f_3mnths\n 2f 3mnths\n \n 2020-06-05 13:04:23 UTC\n \n 2020-07-26 12:43: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 698\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:04:23',4,'2020-07-26 12:43:52',4,0,NULL,NULL,NULL,'c2d8398b-5983-4f3b-b03a-81ca63635377'),(699,'adult_arv_2g_3mnths','2g 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2g_3mnths\n 2g 3mnths\n \n 2020-06-05 13:08:33 UTC\n \n 2020-07-26 12:49: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 699\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:08:33',4,'2020-07-26 12:49:39',4,0,NULL,NULL,NULL,'6a63e39d-88e4-49f2-84d1-63b1a1f1118d'),(700,'adult_arv_2h_3mnths','2h 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2h_3mnths\n 2h 3mnths\n \n 2020-06-05 13:10:20 UTC\n \n 2020-07-26 12:48: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 700\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:10:20',4,'2020-07-26 12:48:18',4,0,NULL,NULL,NULL,'3e13b024-8c5e-4004-b6de-fa643e50b752'),(701,'adult_arv_2j_3mnths','2j 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2j_3mnths\n 2j 3mnths\n \n 2020-06-05 13:11:27 UTC\n \n 2020-07-26 12:51:05 UTC\n \n \n \n \n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 701\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:11:27',4,'2020-07-26 12:51:05',4,0,NULL,NULL,NULL,'1a3b524f-388a-4692-aadf-c2c5c9832870'),(702,'adult_arv_2k_3mnths','2k 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2k_3mnths\n 2k 3mnths\n \n 2020-06-05 13:13:02 UTC\n \n 2020-07-26 12:56: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 702\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:13:02',4,'2020-07-26 12:56:02',4,0,NULL,NULL,NULL,'462e353e-3349-4334-8547-4361d310dd1f'),(703,'adult_arv_2l_3mnths','2l 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2l_3mnths\n 2l 3mnths\n \n 2020-06-05 13:14:56 UTC\n \n 2020-07-26 12:58: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 703\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:14:56',4,'2020-07-26 12:58:05',4,0,NULL,NULL,NULL,'762a506b-5142-4d0b-9a34-7364511b3804'),(704,'4c=AZT-3TC-NVP','4c','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4c=AZT-3TC-NVP\n 4c\n \n 2020-06-05 13:15:30 UTC\n \n 2021-07-01 09: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 704\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:15:30',4,'2021-07-01 09:54:14',4,0,NULL,NULL,NULL,'2333dba3-e4ab-4c96-b28d-b8a55cde3d1d'),(705,'adult_arv_2m_3mnths','2m 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2m_3mnths\n 2m 3mnths\n \n 2020-06-05 13:15:54 UTC\n \n 2020-07-26 13:00: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 705\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:15:54',4,'2020-07-26 13:00:52',4,0,NULL,NULL,NULL,'e39e9c25-717b-4e07-9cf0-9f7f3abfc08e'),(706,'adult_arv_2n_3mnths','2n 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2n_3mnths\n 2n 3mnths\n \n 2020-06-05 13:17:12 UTC\n \n 2020-07-26 13:03: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 706\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:17:12',4,'2020-07-26 13:03:32',4,0,NULL,NULL,NULL,'ff9adb70-4a63-4b77-b3ec-d3425b98afa4'),(707,'4d=AZT-3TC-EFV','4D','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4d=AZT-3TC-EFV\n 4D\n \n 2020-06-05 13:17:34 UTC\n \n 2021-07-01 09: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 707\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:17:34',4,'2021-07-01 09:54:59',4,0,NULL,NULL,NULL,'2090f6ca-5e65-4d41-98e3-b70f29abc483'),(708,'4e=ABC-3TC-NVP','4E','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4e=ABC-3TC-NVP\n 4E\n \n 2020-06-05 13:19:26 UTC\n \n 2021-07-01 09:55: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 708\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:19:26',4,'2021-07-01 09:55:40',4,0,NULL,NULL,NULL,'ee076dba-cc07-4b13-bc62-4d0d32193e03'),(709,'adult_arv_2o_3mnths','2o 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2o_3mnths\n 2o 3mnths\n \n 2020-06-05 13:19:40 UTC\n \n 2020-07-26 13:06: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 709\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:19:40',4,'2020-07-26 13:06:34',4,0,NULL,NULL,NULL,'738cb550-b15d-453e-bb7d-defc4b362956'),(710,'adult_arv_2p_3mnths','2p 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2p_3mnths\n 2p 3mnths\n \n 2020-06-05 13:20:54 UTC\n \n 2020-07-26 13:09: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 710\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:20:54',4,'2020-07-26 13:09:53',4,0,NULL,NULL,NULL,'60662d72-cea5-4ad5-93b0-ce12922fc834'),(711,'adult_arv_2q_3mnths','2q 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2q_3mnths\n 2q 3mnths\n \n 2020-06-05 13:22:02 UTC\n \n 2020-07-26 13:11: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 711\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:22:02',4,'2020-07-26 13:11:26',4,0,NULL,NULL,NULL,'9ea4bf50-06f1-4028-ab9f-d276a5ea38da'),(712,'4f=ABC-3TC-EFV','4F','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4f=ABC-3TC-EFV\n 4F\n \n 2020-06-05 13:22:28 UTC\n \n 2021-07-01 09:56: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 712\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:22:28',4,'2021-07-01 09:56:17',4,0,NULL,NULL,NULL,'eb90af68-e363-449b-810c-f1075ba677f0'),(713,'4g=AZT-3TC-LPV/r','4g','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4g=AZT-3TC-LPV/r\n 4g\n \n 2020-06-05 13:24:33 UTC\n \n 2021-07-01 09: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 713\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:24:33',4,'2021-07-01 09:57:45',4,0,NULL,NULL,NULL,'3da73ab3-5e2d-4416-adf8-69fda1030aff'),(714,'CI20a: Adult 3rd Line 1month supply 3a','3a 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI20a: Adult 3rd Line 1month supply 3a\n 3a 1mnth\n \n 2020-06-05 13:24:35 UTC\n \n 2021-07-13 15:19: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 714\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:24:35',4,'2021-07-13 15:19:02',4,0,NULL,NULL,NULL,'d5ac0964-e25b-4ac9-bde2-216933143835'),(715,'CI21a: Adult 3rd Line 1month supply 3b','3b 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI21a: Adult 3rd Line 1month supply 3b\n 3b 1mnth\n \n 2020-06-05 13:25:50 UTC\n \n 2021-07-13 15:20: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 715\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:25:50',4,'2021-07-13 15:20:07',4,0,NULL,NULL,NULL,'aecf3360-f578-4223-a2b9-8167716b3ded'),(716,'4h=ABC-3TC-LPV/r','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4h=ABC-3TC-LPV/r\n \n \n 2020-06-05 13:25:57 UTC\n \n 2021-07-01 10:01: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 716\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:25:57',4,'2021-07-01 10:01:31',4,0,NULL,NULL,NULL,'ae250ccd-298b-4520-868e-14f945a7cc19'),(717,'CI22a: Adult 3rd Line 1month supply 3c','3c 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI22a: Adult 3rd Line 1month supply 3c\n 3c 1mnth\n \n 2020-06-05 13:26:59 UTC\n \n 2021-07-13 15:20: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 717\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:26:59',4,'2021-07-13 15:20:22',4,0,NULL,NULL,NULL,'9e32a97e-1aec-4924-8e31-c2870428b351'),(718,'4j=TDF-3TC-DTG(TLD)','4J','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4j=TDF-3TC-DTG(TLD)\n 4J\n \n 2020-06-05 13:27:32 UTC\n \n 2021-07-01 10:02: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 718\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:27:32',4,'2021-07-01 10:02:22',4,0,NULL,NULL,NULL,'30e58b2b-51ad-45c4-ba54-dfa0ee46192f'),(719,'CI40a: Adult 3rd Line 1month supply 3d','3d 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI40a: Adult 3rd Line 1month supply 3d\n 3d 1mnth\n \n 2020-06-05 13:28:21 UTC\n \n 2021-07-13 15:23: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 719\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:28:21',4,'2021-07-13 15:23:54',4,0,NULL,NULL,NULL,'e96450ab-af66-468b-9fe6-59e6dc7039a1'),(720,'CI41a: Adult 3rd Line 1month supply 3e','3e 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI41a: Adult 3rd Line 1month supply 3e\n 3e 1mnth\n \n 2020-06-05 13:29:18 UTC\n \n 2021-07-13 15:24: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 720\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:29:18',4,'2021-07-13 15:24:08',4,0,NULL,NULL,NULL,'9b325a21-8147-4294-8de3-11fe91804147'),(721,'Clients newly initiated 4j','4j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4j\n 4j\n \n 2020-06-05 13:30:13 UTC\n \n 2021-01-27 22:27: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 721\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4686 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 13:30:13',4,'2021-01-27 22:27:00',4,0,NULL,NULL,NULL,'98e00266-550e-4ac2-ad86-d1bfd1edad02'),(722,'CI42a: Adult 3rd Line 1month supply 3f','3f 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI42a: Adult 3rd Line 1month supply 3f\n 3f 1mnth\n \n 2020-06-05 13:30:30 UTC\n \n 2021-07-13 15:24: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 722\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:30:30',4,'2021-07-13 15:24:22',4,0,NULL,NULL,NULL,'0ec32115-a8ab-4989-8693-4a3b02a2f57f'),(723,'CI43a: Adult 3rd Line 1month supply 3g','3g 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI43a: Adult 3rd Line 1month supply 3g\n 3g 1mnth\n \n 2020-06-05 13:31:51 UTC\n \n 2021-07-13 15:25: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 723\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:31:51',4,'2021-07-13 15:25:40',4,0,NULL,NULL,NULL,'30f95dc0-e9d9-45e0-8780-13b386d0e1ed'),(724,'4k=ABC-3TC-DTG','4K','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4k=ABC-3TC-DTG\n 4K\n \n 2020-06-05 13:31:57 UTC\n \n 2021-07-01 10:03: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 724\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:31:57',4,'2021-07-01 10:03:27',4,0,NULL,NULL,NULL,'788332e7-cc9f-4abb-983a-9c85c218367e'),(725,'CI44a: Adult 3rd Line 1month supply 3h','3h 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI44a: Adult 3rd Line 1month supply 3h\n 3h 1mnth\n \n 2020-06-05 13:32:56 UTC\n \n 2021-07-13 15:25: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 725\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:32:56',4,'2021-07-13 15:25:58',4,0,NULL,NULL,NULL,'18a4ba21-a27a-41a1-a3a1-407d94e3b6af'),(726,'4L=AZT-3TC-DTG','4L','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4L=AZT-3TC-DTG\n 4L\n \n 2020-06-05 13:33:21 UTC\n \n 2021-07-01 10:03: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 726\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:33:21',4,'2021-07-01 10:03:40',4,0,NULL,NULL,NULL,'9e98473d-8542-491f-ba7a-72eed5bb8cc9'),(727,'5a=AZT-3TC-LPV/r','5a','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 5a=AZT-3TC-LPV/r\n 5a\n \n 2020-06-05 13:37:09 UTC\n \n 2021-07-01 10:04: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 727\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:37:09',4,'2021-07-01 10:04:56',4,0,NULL,NULL,NULL,'90e1122b-ae81-4c9a-85bd-4718d62e8555'),(728,'5b=ABC-3TC-LPV/r','5B','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 5b=ABC-3TC-LPV/r\n 5B\n \n 2020-06-05 13:38:40 UTC\n \n 2021-07-01 10:05: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 728\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:38:40',4,'2021-07-01 10:05:12',4,0,NULL,NULL,NULL,'5724ff33-4897-408c-8c0f-bd4f492421cf'),(729,'5c=ABC-3TC-DRV/r','5C','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 5c=ABC-3TC-DRV/r\n 5C\n \n 2020-06-05 13:41:08 UTC\n \n 2021-07-01 10:06: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 729\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:41:08',4,'2021-07-01 10:06:05',4,0,NULL,NULL,NULL,'fcba5f96-f8b0-4cee-a432-d8a812214c91'),(730,'5d=AZT-3TC-DRV/r','5D','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 5d=AZT-3TC-DRV/r\n 5D\n \n 2020-06-05 13:43:45 UTC\n \n 2021-07-01 10: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 730\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:43:45',4,'2021-07-01 10:06:20',4,0,NULL,NULL,NULL,'c755ea49-186f-44fc-b6c6-9063230d3480'),(731,'5e=AZT-3TC-ABC','5e','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 5e=AZT-3TC-ABC\n 5e\n \n 2020-06-05 13:44:53 UTC\n \n 2021-07-01 10:07: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 731\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:44:53',4,'2021-07-01 10:07:11',4,0,NULL,NULL,NULL,'19dddce8-40b7-4851-ae3a-c3a1cb14eb91'),(732,'5f=AZT-3TC-DTG','5f','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 5f=AZT-3TC-DTG\n 5f\n \n 2020-06-05 13:47:24 UTC\n \n 2021-07-01 10:07: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 732\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:47:24',4,'2021-07-01 10:07:29',4,0,NULL,NULL,NULL,'949e2eab-7153-4142-b71a-59e1a1defede'),(733,'Clients newly initiated 5f','5f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 5f\n 5f\n \n 2020-06-05 13:48:37 UTC\n \n 2021-01-27 22: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 733\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4699 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 13:48:37',4,'2021-01-27 22:42:15',4,0,NULL,NULL,NULL,'c2568b3b-6226-4d7b-a190-b337501d1731'),(734,'5g=AZT-3TC-ATVr/','5G','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 5g=AZT-3TC-ATVr/\n 5G\n \n 2020-06-05 13:50:29 UTC\n \n 2021-07-01 10: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 734\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:50:29',4,'2021-07-01 10:08:22',4,0,NULL,NULL,NULL,'286bc570-0ccd-48ff-862d-211475082a7a'),(735,'5h=ABC-3TC-ATV/r','5h','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 5h=ABC-3TC-ATV/r\n 5h\n \n 2020-06-05 13:52:03 UTC\n \n 2021-07-01 10:09: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 735\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:52:03',4,'2021-07-01 10:09:01',4,0,NULL,NULL,NULL,'8d6b09b2-2781-4559-bfc0-a3c5678536b4'),(736,'6a=RAL-ETV-LPV/r','6a','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 6a=RAL-ETV-LPV/r\n 6a\n \n 2020-06-05 13:53:49 UTC\n \n 2021-07-01 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 736\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:53:49',4,'2021-07-01 10:09:36',4,0,NULL,NULL,NULL,'23792b6c-5b46-4a98-9fe6-1d26d4f91e9e'),(737,'6b=RAL-ETV-DRV/r','6b','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 6b=RAL-ETV-DRV/r\n 6b\n \n 2020-06-05 13:55:09 UTC\n \n 2021-07-01 10:09: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 737\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:55:09',4,'2021-07-01 10:09:59',4,0,NULL,NULL,NULL,'5449106c-244d-4d19-ad83-bba3f01589e7'),(738,'6c=RAL+ETV+DRV/r','6C','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 6c=RAL+ETV+DRV/r\n 6C\n \n 2020-06-05 13:57:19 UTC\n \n 2021-07-01 10:10: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 738\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:57:19',4,'2021-07-01 10:10:51',4,0,NULL,NULL,NULL,'aa99445e-54bd-4de8-9ef1-9a888fd68239'),(739,'6d=TDF-3TC-DRV/r+RAL','6D','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 6d=TDF-3TC-DRV/r+RAL\n 6D\n \n 2020-06-05 13:59:01 UTC\n \n 2021-07-01 10:11: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 739\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:59:01',4,'2021-07-01 10:11:04',4,0,NULL,NULL,NULL,'367ded00-770e-478f-a366-2c5ca91c2567'),(740,'6e=RAL+DRV/r','6E','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 6e=RAL+DRV/r\n 6E\n \n 2020-06-05 14:00:26 UTC\n \n 2021-07-01 10:12: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 740\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 14:00:26',4,'2021-07-01 10:12:05',4,0,NULL,NULL,NULL,'a8e0b35d-cf9a-4f1f-8995-c7a9e28b1103'),(741,'6f=AZT+3TC+DRV/r+ETV','6F','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 6f=AZT+3TC+DRV/r+ETV\n 6F\n \n 2020-06-05 14:02:22 UTC\n \n 2021-07-01 10: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 741\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 14:02:22',4,'2021-07-01 10:12:20',4,0,NULL,NULL,NULL,'0952cfb3-6f9b-4d27-b94b-4c25ba0c99e7'),(742,'Cotrimox Prophylaxis/Dapsone','CTX','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Cotrimox Prophylaxis/Dapsone\n CTX\n \n 2020-06-05 14:06:03 UTC\n \n 2020-06-05 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 742\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 16:06:03',4,'2020-06-05 16:06:48',4,0,NULL,NULL,NULL,'12dfb355-bf17-4ee3-a267-b047f38a89b8'),(743,'Missed or defaulted under 28days','missed appointments under 28 days','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Missed or defaulted under 28days\n missed appointments under 28 days\n \n 2020-06-05 14:06:51 UTC\n \n 2020-06-05 14:08: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 743\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 16:06:51',4,'2020-06-05 16:08:00',4,0,NULL,NULL,NULL,'26fb300b-c224-45ae-a82e-94786101c82d'),(744,'RUFT','Plumpy-nut','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n RUFT\n Plumpy-nut\n \n 2020-06-05 14:08:10 UTC\n \n 2020-06-05 14:09: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 744\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 16:08:10',4,'2020-06-05 16:09:03',4,0,NULL,NULL,NULL,'e72ff52c-b8c7-4728-bf7b-747e208b3e06'),(745,'Missed or defaulted between 29 and 89 days','Missed or defaulted between 29 and 89 days','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Missed or defaulted between 29 and 89 days\n Missed or defaulted between 29 and 89 days\n \n 2020-06-05 14:08:54 UTC\n \n 2020-06-05 14:09: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 745\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 16:08:54',4,'2020-06-05 16:09:29',4,0,NULL,NULL,NULL,'6ec03f54-c1f7-49b4-9332-c7c9aa994579'),(746,'Given F100 in the month','F100','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Given F100 in the month\n F100\n \n 2020-06-05 14:09:44 UTC\n \n 2020-06-05 14:10: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 746\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 16:09:44',4,'2020-06-05 16:10:29',4,0,NULL,NULL,NULL,'052f159f-57d1-4597-94ae-d81c0876610d'),(747,'Given F75 in the month','F75','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Given F75 in the month\n F75\n \n 2020-06-05 14:10:52 UTC\n \n 2020-06-05 14:12: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 747\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 16:10:52',4,'2020-06-05 16:12:03',4,0,NULL,NULL,NULL,'a63995e1-38a2-4c49-8189-7e2eff852513'),(748,'Other Nutritional Supplement given in the month','other','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Other Nutritional Supplement given in the month\n other\n \n 2020-06-05 14:12:35 UTC\n \n 2020-06-05 14:13: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 748\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 16:12:35',4,'2020-06-05 16:13:16',4,0,NULL,NULL,NULL,'092667a0-a0a3-4f6e-b25d-963a76c74814'),(750,'Children ARV Regimen 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 Data Set\n \n 2020-06-05 14:19:22 UTC\n \n 2020-06-05 16:09: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 750\n \n \n DM_Weight\n \n \n \n \n \n \n \n \n 4L03to3.9\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_Weight\n 03to3.9kg\n \n \n \n \n \n 4L10to13.9\n \n \n \n \n DM_Weight\n 10to13.9kg\n \n \n \n \n \n 4L14to19.9\n \n \n \n \n DM_Weight\n 14to19.9kg\n \n \n \n \n \n 4L20to24.9\n \n \n \n \n DM_Weight\n 20to24.9kg\n \n \n \n \n \n 4L25to34.9\n \n \n \n \n DM_Weight\n 25to34.9kg\n \n \n \n \n \n 4L4to5.9\n \n \n \n \n DM_Weight\n 04to5.9kg\n \n \n \n \n \n 4L6to9.9\n \n \n \n \n DM_Weight\n 06to9.9kg\n \n \n \n \n \n 4c03to3.9\n \n \n \n \n \n \n \n \n \n 4c10to13.9\n \n \n \n \n \n \n 4c14to19.9\n \n \n \n \n \n \n 4c20to24.9\n \n \n \n \n \n \n 4c25to34.9\n \n \n \n \n \n \n 4c4to5.9\n \n \n \n \n \n \n 4c6to9.9\n \n \n \n \n \n \n 4d0.3to3.9\n \n \n \n \n \n \n \n \n \n 4d10to13.9\n \n \n \n \n \n \n 4d14to19.9\n \n \n \n \n \n \n 4d20to24.9\n \n \n \n \n \n \n 4d25to34.9\n \n \n \n \n \n \n 4d4to5.9\n \n \n \n \n \n \n 4d6to9.9\n \n \n \n \n \n \n 4e0.3to3.9\n \n \n \n \n \n \n \n \n \n 4e10to13.9\n \n \n \n \n \n \n 4e14to19.9\n \n \n \n \n \n \n 4e20to24.9\n \n \n \n \n \n \n 4e25to34.9\n \n \n \n \n \n \n 4e4to5.9\n \n \n \n \n \n \n 4e6to9.9\n \n \n \n \n \n \n 4f0.3to3.9\n \n \n \n \n \n \n \n \n \n 4f10to13.9\n \n \n \n \n \n \n 4f14to19.9\n \n \n \n \n \n \n 4f20to24.9\n \n \n \n \n \n \n 4f25to34.9\n \n \n \n \n \n \n 4f4to5.9\n \n \n \n \n \n \n 4f6to9.9\n \n \n \n \n \n \n 4g0.3to3.9\n \n \n \n \n \n \n \n \n \n 4g10to13.9\n \n \n \n \n \n \n 4g14to19.9\n \n \n \n \n \n \n 4g20to24.9\n \n \n \n \n \n \n 4g25to34.9\n \n \n \n \n \n \n 4g4to5.9\n \n \n \n \n \n \n 4g6to9.9\n \n \n \n \n \n \n 4h0.3to3.9\n \n \n \n \n \n \n \n \n \n 4h10to13.9\n \n \n \n \n \n \n 4h14to19.9\n \n \n \n \n \n \n 4h20to24.9\n \n \n \n \n \n \n 4h25to34.9\n \n \n \n \n \n \n 4h4to5.9\n \n \n \n \n \n \n 4h6to9.9\n \n \n \n \n \n \n 4j0.3to3.9\n \n \n \n \n \n \n \n \n \n 4j10to13.9\n \n \n \n \n \n \n 4j14to19.9\n \n \n \n \n \n \n 4j20to24.9\n \n \n \n \n \n \n 4j25to34.9\n \n \n \n \n \n \n 4j4to5.9\n \n \n \n \n \n \n 4j6to9.9\n \n \n \n \n \n \n 4k0.3to3.9\n \n \n \n \n \n \n \n \n \n 4k10to13.9\n \n \n \n \n \n \n 4k14to19.9\n \n \n \n \n \n \n 4k20to24.9\n \n \n \n \n \n \n 4k25to34.9\n \n \n \n \n \n \n 4k4to5.9\n \n \n \n \n \n \n 4k6to9.9\n \n \n \n \n \n \n','2020-06-05 16:19:22',4,'2020-06-05 18:09:53',4,0,NULL,NULL,NULL,'86987ed4-9fb6-46c9-9376-124ca29b26cb'),(751,'Stopped ART this month','stopped this month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Stopped ART this month\n stopped this month\n \n 2020-06-05 15:34:17 UTC\n \n 2020-06-05 15:37: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 751\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 17:34:17',4,'2020-06-05 17:37:55',4,0,NULL,NULL,NULL,'3339dfc7-cd36-4231-b31e-5390963065ab'),(752,'2020_adult_arv_1stline_regimen','new dataset ADULT ARV REGIMEN AT THE END OF THE MONTH (15+)','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_adult_arv_1stline_regimen\n new dataset ADULT ARV REGIMEN AT THE END OF THE MONTH (15+)\n \n 2020-06-05 15:51:46 UTC\n \n 2020-07-26 09:11: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 752\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','2020-06-05 15:51:46',4,'2020-07-26 09:11:25',4,0,NULL,NULL,NULL,'bf495055-881f-4d8f-a313-034368641292'),(753,'2020_ADULT ARV REGIMEN AT THE END OF THE MONTH (15+) Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_ADULT ARV REGIMEN AT THE END OF THE MONTH (15+) Data Set\n \n 2020-06-05 15:51:49 UTC\n \n 2021-01-27 14:00: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 753\n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 1c_1mnth\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_Age\n 15+yrs\n \n \n \n \n \n 1c_3mnths\n \n \n \n \n \n \n \n \n \n 1c_6mnths\n \n \n \n \n \n \n \n \n \n 1c_other\n \n \n \n \n \n \n \n \n \n 1d_1mnth\n \n \n \n \n \n \n \n \n \n 1d_3mnths\n \n \n \n \n \n \n \n \n \n 1d_6mnths\n \n \n \n \n \n \n \n \n \n 1d_other\n \n \n \n \n \n \n \n \n \n 1e_1mnth\n \n \n \n \n \n \n \n \n \n 1e_3mnths\n \n \n \n \n \n \n \n \n \n 1e_6mnths\n \n \n \n \n \n \n \n \n \n 1e_other\n \n \n \n \n \n \n \n \n \n 1f_1mnth\n \n \n \n \n \n \n \n \n \n 1f_3mnths\n \n \n \n \n \n \n \n \n \n 1f_6mnths\n \n \n \n \n \n \n \n \n \n 1f_othmnth\n \n \n \n \n \n \n \n \n \n 1g_1mnth\n \n \n \n \n \n \n \n \n \n 1g_3mnths\n \n \n \n \n \n \n \n \n \n 1g_6mnths\n \n \n \n \n \n \n \n \n \n 1g_other\n \n \n \n \n \n \n \n \n \n 1h_1mnth\n \n \n \n \n \n \n \n \n \n 1h_3mnths\n \n \n \n \n \n \n \n \n \n 1h_6mnths\n \n \n \n \n \n \n \n \n \n 1h_other\n \n \n \n \n \n \n \n \n \n 1j_1mnth\n \n \n \n \n \n \n \n \n \n 1j_3mnths\n \n \n \n \n \n \n \n \n \n 1j_6mnths\n \n \n \n \n \n \n \n \n \n 1j_other\n \n \n \n \n \n \n \n \n \n 1k_1mnth\n \n \n \n \n \n \n \n \n \n 1k_3mnths\n \n \n \n \n \n \n \n \n \n 1k_6mnths\n \n \n \n \n \n \n \n \n \n 1k_other\n \n \n \n \n \n \n \n \n \n 1m_1mnth\n \n \n \n \n \n \n \n \n \n 1m_3mnths\n \n \n \n \n \n \n \n \n \n 1m_6mnths\n \n \n \n \n \n \n \n \n \n 1m_other\n \n \n \n \n \n \n \n \n \n 1n_1mnth\n \n \n \n \n \n \n \n \n \n 1n_3mnths\n \n \n \n \n \n \n \n \n \n 1n_6mnths\n \n \n \n \n \n \n \n \n \n 1n_other\n \n \n \n \n \n \n \n \n \n 1p_1mnth\n \n \n \n \n \n \n \n \n \n 1p_3mnths\n \n \n \n \n \n \n \n \n \n 1p_6mnths\n \n \n \n \n \n \n \n \n \n 1p_other\n \n \n \n \n \n \n \n \n \n 1q_1mnth\n \n \n \n \n \n \n \n \n \n 1q_3mnths\n \n \n \n \n \n \n \n \n \n 1q_6mnths\n \n \n \n \n \n \n \n \n \n 1q_other\n \n \n \n \n \n \n \n \n \n other_1mnt\n \n \n \n \n \n \n \n \n \n other_3mnt\n \n \n \n \n \n \n \n \n \n other_6mnt\n \n \n \n \n \n \n \n \n \n other_othe\n \n \n \n \n \n \n \n \n \n','2020-06-05 15:51:49',4,'2021-01-27 14:00:34',4,0,NULL,NULL,NULL,'48bdf3d1-3a1a-46b1-a53a-7db8f1a24781'),(755,'Children ARV Regimen_2ndLine 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 Data Set\n \n 2020-06-06 16:40:08 UTC\n \n 2020-06-06 17:59: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 755\n \n \n DM_Weight\n \n \n \n \n \n \n \n \n 5a10to13.9\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_Weight\n 10to13.9kg\n \n \n \n \n \n 5a14to19.9\n \n \n \n \n DM_Weight\n 14to19.9kg\n \n \n \n \n \n 5a20to24.9\n \n \n \n \n DM_Weight\n 20to24.9kg\n \n \n \n \n \n 5a25to34.9\n \n \n \n \n DM_Weight\n 25to34.9kg\n \n \n \n \n \n 5a3to3.9\n \n \n \n \n DM_Weight\n 03to3.9kg\n \n \n \n \n \n 5a4to5.9\n \n \n \n \n DM_Weight\n 04to5.9kg\n \n \n \n \n \n 5a6to9.9\n \n \n \n \n DM_Weight\n 06to9.9kg\n \n \n \n \n \n 5b10to13.9\n \n \n \n \n \n \n \n \n \n 5b14to19.9\n \n \n \n \n \n \n 5b20to24.9\n \n \n \n \n \n \n 5b25to34.9\n \n \n \n \n \n \n 5b3to3.9\n \n \n \n \n \n \n 5b4to5.9\n \n \n \n \n \n \n 5b6to9.9\n \n \n \n \n \n \n 5c10to13.9\n \n \n \n \n \n \n \n \n \n 5c14to19.9\n \n \n \n \n \n \n 5c20to24.9\n \n \n \n \n \n \n 5c25to34.9\n \n \n \n \n \n \n 5c3to3.9\n \n \n \n \n \n \n 5c4to5.9\n \n \n \n \n \n \n 5c6to9.9\n \n \n \n \n \n \n 5d10to13.9\n \n \n \n \n \n \n \n \n \n 5d14to19.9\n \n \n \n \n \n \n 5d20to24.9\n \n \n \n \n \n \n 5d25to34.9\n \n \n \n \n \n \n 5d3to3.9\n \n \n \n \n \n \n 5d4to5.9\n \n \n \n \n \n \n 5d6to9.9\n \n \n \n \n \n \n 5e10to13.9\n \n \n \n \n \n \n \n \n \n 5e14to19.9\n \n \n \n \n \n \n 5e20to24.9\n \n \n \n \n \n \n 5e25to34.9\n \n \n \n \n \n \n 5e3to3.9\n \n \n \n \n \n \n 5e4to5.9\n \n \n \n \n \n \n 5e6to9.9\n \n \n \n \n \n \n 5f10to13.9\n \n \n \n \n \n \n \n \n \n 5f14to19.9\n \n \n \n \n \n \n 5f20to24.9\n \n \n \n \n \n \n 5f25to34.9\n \n \n \n \n \n \n 5f3to3.9\n \n \n \n \n \n \n 5f4to5.9\n \n \n \n \n \n \n 5f6to9.9\n \n \n \n \n \n \n 5g10to13.9\n \n \n \n \n \n \n \n \n \n 5g14to19.9\n \n \n \n \n \n \n 5g20to24.9\n \n \n \n \n \n \n 5g25to34.9\n \n \n \n \n \n \n 5g3to3.9\n \n \n \n \n \n \n 5g4to5.9\n \n \n \n \n \n \n 5g6to9.9\n \n \n \n \n \n \n 5h10to13.9\n \n \n \n \n \n \n \n \n \n 5h14to19.9\n \n \n \n \n \n \n 5h20to24.9\n \n \n \n \n \n \n 5h25to34.9\n \n \n \n \n \n \n 5h3to3.9\n \n \n \n \n \n \n 5h4to5.9\n \n \n \n \n \n \n 5h6to9.9\n \n \n \n \n \n \n','2020-06-06 18:40:08',4,'2020-06-06 19:59:56',4,0,NULL,NULL,NULL,'b544b920-9355-4cde-91ef-1abce8a0666c'),(756,'Clients given CTX in the month','Clients given CTX in the month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given CTX in the month\n Clients given CTX in the month\n \n 2020-06-06 17:51:03 UTC\n \n 2020-06-06 17:52: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 756\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-06 19:51:03',4,'2020-06-06 19:52:29',4,0,NULL,NULL,NULL,'9227d423-f843-4299-866e-c0ef068a8faa'),(758,'Children ARV Regimen_3rdLine 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 Data Set\n \n 2020-06-06 18:10:43 UTC\n \n 2020-06-08 08:32: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 758\n \n \n DM_Weight\n \n \n \n \n \n \n \n \n 6a10to13.9\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_Weight\n 10to13.9kg\n \n \n \n \n \n 6a14to19.9\n \n \n \n \n DM_Weight\n 14to19.9kg\n \n \n \n \n \n 6a20to24.9\n \n \n \n \n DM_Weight\n 20to24.9kg\n \n \n \n \n \n 6a25to34.9\n \n \n \n \n DM_Weight\n 25to34.9kg\n \n \n \n \n \n 6a3to3.9\n \n \n \n \n DM_Weight\n 03to3.9kg\n \n \n \n \n \n 6a4to5.9\n \n \n \n \n DM_Weight\n 04to5.9kg\n \n \n \n \n \n 6a6to9.9\n \n \n \n \n DM_Weight\n 06to9.9kg\n \n \n \n \n \n 6b10to13.9\n \n \n \n \n \n \n \n \n \n 6b14to19.9\n \n \n \n \n \n \n 6b20to24.9\n \n \n \n \n \n \n 6b25to34.9\n \n \n \n \n \n \n 6b3to3.9\n \n \n \n \n \n \n 6b4to5.9\n \n \n \n \n \n \n 6b6to9.9\n \n \n \n \n \n \n 6c10to13.9\n \n \n \n \n \n \n \n \n \n 6c14to19.9\n \n \n \n \n \n \n 6c20to24.9\n \n \n \n \n \n \n 6c25to34.9\n \n \n \n \n \n \n 6c3to3.9\n \n \n \n \n \n \n 6c4to5.9\n \n \n \n \n \n \n 6c6to9.9\n \n \n \n \n \n \n 6d10to13.9\n \n \n \n \n \n \n \n \n \n 6d14to19.9\n \n \n \n \n \n \n 6d20to24.9\n \n \n \n \n \n \n 6d25to34.9\n \n \n \n \n \n \n 6d3to3.9\n \n \n \n \n \n \n 6d4to5.9\n \n \n \n \n \n \n 6d6to9.9\n \n \n \n \n \n \n 6e10to13.9\n \n \n \n \n \n \n \n \n \n 6e14to19.9\n \n \n \n \n \n \n 6e20to24.9\n \n \n \n \n \n \n 6e25to34.9\n \n \n \n \n \n \n 6e3to3.9\n \n \n \n \n \n \n 6e4to5.9\n \n \n \n \n \n \n 6e6to9.9\n \n \n \n \n \n \n 6f10to13.9\n \n \n \n \n \n \n \n \n \n 6f14to19.9\n \n \n \n \n \n \n 6f20to24.9\n \n \n \n \n \n \n 6f25to34.9\n \n \n \n \n \n \n 6f3to3.9\n \n \n \n \n \n \n 6f4to5.9\n \n \n \n \n \n \n 6f6to9.9\n \n \n \n \n \n \n','2020-06-06 20:10:43',4,'2020-06-08 10:32:22',4,0,NULL,NULL,NULL,'6e3a006d-98ce-4042-9850-7ba6ccfadebe'),(759,'2020_NUTRITIONAL SUPPLEMENT','new dataset NUTRITIONAL SUPPLEMENT','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_NUTRITIONAL SUPPLEMENT\n new dataset NUTRITIONAL SUPPLEMENT\n \n 2020-06-06 18:19:59 UTC\n \n 2020-06-06 18:20: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 759\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','2020-06-06 20:19:59',4,'2020-06-06 20:20:03',4,0,NULL,NULL,NULL,'bb75a854-ddeb-4ce5-b822-f76dd8bf22ad'),(760,'2020_NUTRITIONAL SUPPLEMENT Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_NUTRITIONAL SUPPLEMENT Data Set\n \n 2020-06-06 18:20:03 UTC\n \n 2020-06-08 10:00: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 760\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 F100FAdult\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 Adults\n \n \n \n \n \n F100FChild\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n F100MAdult\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Adults\n \n \n \n \n \n F100MChild\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n F75FAdult\n \n \n \n \n \n \n \n \n \n F75FChild\n \n \n \n \n \n \n F75MAdult\n \n \n \n \n \n \n F75MChild\n \n \n \n \n \n \n OtherFAdul\n \n \n \n \n \n \n \n \n \n OtherFChil\n \n \n \n \n \n \n OtherMAdul\n \n \n \n \n \n \n OtherMChil\n \n \n \n \n \n \n PlumpFAdul\n \n \n \n \n \n \n \n \n \n PlumpFChil\n \n \n \n \n \n \n PlumpMAdul\n \n \n \n \n \n \n PlumpMChil\n \n \n \n \n \n \n cereal-F14\n \n \n \n \n \n \n \n \n \n cereal_F15\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 15+yrs\n \n \n \n \n \n cereal-M14\n \n \n \n \n \n \n cereal_M15\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 15+yrs\n \n \n \n \n \n','2020-06-06 20:20:03',4,'2020-06-08 12:00:54',4,0,NULL,NULL,NULL,'acc0e9d9-fe35-4d6d-8707-818221deeaa9'),(761,'Plumpy Nut given in the month','Plumpy Nut given in the month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Plumpy Nut given in the month\n Plumpy Nut given in the month\n \n 2020-06-06 18:30:00 UTC\n \n 2020-06-06 18:30: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 761\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-06 20:30:00',4,'2020-06-06 20:30:55',4,0,NULL,NULL,NULL,'1a8809c1-0866-4b11-8ed9-2ca4fc02154e'),(762,'F100 given in the month','F100 given in the month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n F100 given in the month\n F100 given in the month\n \n 2020-06-06 18:32:13 UTC\n \n 2020-06-06 18:33: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 762\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-06 20:32:13',4,'2020-06-06 20:33:54',4,0,NULL,NULL,NULL,'5d68b260-ac27-417d-b075-27c258ed6e5d'),(763,'F75 given in the month','F75 given in the month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n F75 given in the month\n F75 given in the month\n \n 2020-06-06 18:34:41 UTC\n \n 2020-06-06 18: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 763\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-06 20:34:41',4,'2020-06-06 20:35:51',4,0,NULL,NULL,NULL,'f72d3c94-b272-489a-af95-c198ac632230'),(764,'Other Nutritional Supplement given in the month','Other Nutritional Supplement given in the month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Other Nutritional Supplement given in the month\n Other Nutritional Supplement given in the month\n \n 2020-06-06 18:37:18 UTC\n \n 2020-06-06 18:38: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 764\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-06 20:37:18',4,'2020-06-06 20:38:33',4,0,NULL,NULL,NULL,'49f802d9-a927-432f-9ecc-5320277583a1'),(765,'Given Super Cereal in the month','super cereal','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Given Super Cereal in the month\n super cereal\n \n 2020-06-08 09:14:51 UTC\n \n 2020-07-07 10:18: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 765\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand obs_datetime BETWEEN :startDate AND :endDate \nand concept_id = 4167 and value_coded = 4815\n','2020-06-08 09:14:51',4,'2020-07-07 10:18:22',4,0,NULL,NULL,NULL,'7e88e4d8-d827-49ba-85ce-942847494e02'),(766,'Given Super Cereal in the month','super cereal','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Given Super Cereal in the month\n super cereal\n \n 2020-06-08 09:16:05 UTC\n \n 2020-06-08 09:16: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 766\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-08 11:16:05',4,'2020-06-08 11:16:54',4,0,NULL,NULL,NULL,'7873e38f-7b02-46fc-8002-a0e6fcc7bde8'),(768,'testing Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n testing Data Set\n \n 2020-06-16 09:29:58 UTC\n \n 2020-06-16 09:35: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 768\n \n \n DM_Weight\n \n \n \n \n \n \n \n \n 1\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_Weight\n 03to3.9kg\n \n \n \n \n \n 2\n \n \n \n \n DM_Weight\n 06to9.9kg\n \n \n \n \n \n 3\n \n \n \n \n DM_Weight\n 10to13.9kg\n \n \n \n \n \n 4\n \n \n \n \n DM_Weight\n 14to19.9kg\n \n \n \n \n \n 5\n \n \n \n \n DM_Weight\n 20to24.9kg\n \n \n \n \n \n 6\n \n \n \n \n DM_Weight\n 25to34.9kg\n \n \n \n \n \n','2020-06-16 09:29:58',4,'2020-06-16 09:35:38',4,0,NULL,NULL,NULL,'bf5ad6aa-84e3-4553-8feb-3c3f5a6b7270'),(769,'Clients enrolled this month','Clients enrolled this month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients enrolled this month\n Clients enrolled this month\n \n 2020-06-19 08:31:52 UTC\n \n 2022-04-26 14:50: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 769\n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n -- Retesting Results Pos \n INNER JOIN person ON person.person_id = o.person_id \n where o.concept_id = 4817 and o.value_coded = 1738 \n AND o.voided = 0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND o.person_id in( \n select distinct os.person_id \n from obs os \n -- Not Linked to Care \n where os.concept_id = 4239 and os.value_coded = 2147 \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','2020-06-19 08:31:52',4,'2022-04-26 14:50:16',4,0,NULL,NULL,NULL,'7037562b-4e82-493e-8858-78e0d5d8fbbf'),(770,'Clients ever enrolled on PrE ART','Clients ever enrolled on care','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients ever enrolled on PrE ART\n Clients ever enrolled on care\n \n 2020-06-19 08:35:31 UTC\n \n 2022-04-27 09:49: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 770\n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n -- Retesting Results Positive \n INNER JOIN person ON person.person_id = o.person_id \n where o.concept_id = 4817 and o.value_coded = 1738 \n AND o.voided = 0 \n AND o.person_id in( \n select distinct os.person_id \n from obs os \n -- Not Linked to Care \n where os.concept_id = 4239 and os.value_coded = 2147 \n and os.voided = 0 \n ) \n AND o.person_id not in ( \n -- Current period Pre-ART \n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n -- Retesting Results Pos \n INNER JOIN person ON person.person_id = o.person_id \n where o.concept_id = 4817 and o.value_coded = 1738 \n AND o.voided = 0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND o.person_id in( \n select distinct os.person_id \n from obs os \n -- Not Linked to Care \n where os.concept_id = 4239 and os.value_coded = 2147 \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 \n )\n','2020-06-19 08:35:31',4,'2022-04-27 09:49:54',4,0,NULL,NULL,NULL,'ca1c2a0a-48f5-4370-b46a-2678e49bc163'),(771,'ART and Pre ART Seen this month','ART and Pre ART Seen this month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART and Pre ART Seen this month\n ART and Pre ART Seen this month\n \n 2020-06-19 08:43:33 UTC\n \n 2022-07-25 14:49: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 771\n select distinct person_id \nfrom \n((select distinct o.person_id \nfrom obs o \n-- CLIENTS PHYSICALLY SEEN FOR ART \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id AND person.voided = 0 \n WHERE o.concept_id = 3843 AND o.value_coded = 3842 \n AND MONTH(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND o.voided = 0 \n ) \n \nUNION \n \n( \n-- PreART \nselect distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n -- Retesting Results Pos \n INNER JOIN person ON person.person_id = o.person_id \n where o.concept_id = 4817 and o.value_coded = 1738 \n AND o.voided = 0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND o.person_id in( \n select distinct os.person_id \n from obs os \n -- Not Linked to Care \n where os.concept_id = 4239 and os.value_coded = 2147 \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))AS Seen_and_PreART\n','2020-06-19 08:43:33',4,'2022-07-25 14:49:01',4,0,NULL,NULL,NULL,'05ced471-b115-479a-976c-318595d37af4'),(772,'ART and Pre ART Screened this month','screened','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART and Pre ART Screened this month\n screened\n \n 2020-06-19 09:06:15 UTC\n \n 2022-07-25 15:24: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 772\n select distinct id \nfrom \n( \n(select distinct o.person_id as id \nfrom obs o \n-- CLIENTS PHYSICALLY SEEN FOR ART \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id AND person.voided = 0 \n WHERE o.concept_id = 3843 AND o.value_coded = 3842 \n AND MONTH(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND o.voided = 0 \n AND (o.location_id =:location or parent_location =:location) \n AND o.person_id in ( \n -- TB Screening \n select distinct os.person_id from obs os \n where os.concept_id = 3710 \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 \nUNION \n \n(select HTS_TB_Screening.person_id \nfrom \n(select B.person_id \n from obs B \n inner join location l on B.location_id = l.location_id \n INNER JOIN person ON person.person_id = B.person_id AND person.voided = 0 \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n -- HTS Form \n from obs where concept_id = 2386 \n and obs_datetime <= cast(:endDate as date) \n AND MONTH(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(obs_datetime) = YEAR(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 -- TB Screening \n where concept_id = 2294 and value_coded = 2146 \n and A.observation_id = B.obs_group_id \n and B.voided = 0 \n group by B.person_id) as HTS_TB_Screening \n inner join \n -- and A.person_id in ( \n ( \n -- PREART Clients \n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n -- Retesting Results Pos \n INNER JOIN person ON person.person_id = o.person_id \n where o.concept_id = 4817 and o.value_coded = 1738 \n AND o.voided = 0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND o.person_id in( \n select distinct os.person_id \n from obs os \n -- Not Linked to Care \n where os.concept_id = 4239 and os.value_coded = 2147 \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 ) Pre_ART \n on HTS_TB_Screening.person_id = Pre_ART.person_id \n ))TB_Screening_ART_and_PreART\n','2020-06-19 09:06:15',4,'2022-07-25 15:24:46',4,0,NULL,NULL,NULL,'71bce2a2-eb67-4815-b88a-27b4cd6c99ba'),(773,'Presumptive TB cases this month','Presumptive TB cases this month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Presumptive TB cases this month\n Presumptive TB cases this month\n \n 2020-06-19 09:10:24 UTC\n \n 2020-06-19 09:11: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 773\n select distinct o.person_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \n AND o.concept_id = 3843 AND o.value_coded in (3841,3842) \n AND MONTH(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND o.voided = 0 \n INNER JOIN person ON person.person_id = o.person_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in ( \n select person_id from obs \n where concept_id = 2223 \n ) \n \nand o.person_id in ( \n select person_id from obs \n where concept_id = 3710 and value_coded = 1876 \n AND MONTH(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n )\n','2020-06-19 09:10:24',4,'2020-06-19 09:11:43',4,0,NULL,NULL,NULL,'8a81c8cf-900c-4465-a136-5aba898d64d4'),(774,'Presumptive TB cases diagnosed with TB','diagnosed with TB','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Presumptive TB cases diagnosed with TB\n diagnosed with TB\n \n 2020-06-23 09:51:11 UTC\n \n 2020-06-23 09:54: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 774\n select person_id from obs \n -- genexpert \n where concept_id = 3787 and value_coded in (3816,3817) \n AND MONTH(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n -- line probe \n UNION \n select person_id from obs \n where concept_id = 3805 and value_coded in (1738) \n AND MONTH(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n UNION \n -- phenotypic \n select person_id from obs \n where concept_id = 3840 and value_coded in (3837,3838,3839) \n AND MONTH(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(obs_datetime) = YEAR(CAST(:endDate AS DATE))\n','2020-06-23 09:51:11',4,'2020-06-23 09:54:51',4,0,NULL,NULL,NULL,'4d3236b4-cfb1-47cd-b616-9378de1a8d70'),(775,'Diagnosed with TB and started treatment this month','started TB this month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Diagnosed with TB and started treatment this month\n started TB this month\n \n 2020-06-23 09:58:58 UTC\n \n 2020-06-23 09: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 775\n select person_id from obs \nwhere concept_id = 2237 \nAND MONTH(value_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(value_datetime) = YEAR(CAST(:endDate AS DATE))\n','2020-06-23 09:58:58',4,'2020-06-23 09:59:24',4,0,NULL,NULL,NULL,'59423bc1-bdc8-467a-ad52-32e51434cfc9'),(776,'client_arv_1f','Clients given 1f regimen during reporting period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n client_arv_1f\n Clients given 1f regimen during reporting period\n \n 2020-07-18 19:58:37 UTC\n \n','2020-07-18 19:58:37',4,NULL,NULL,0,NULL,NULL,NULL,'134439b8-8727-4186-a4d1-07d8eb8df1ec'),(777,'ARV Regimen 1f TDF-3TC-EFV SQL','Clients given 1f regimen during reporting period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV Regimen 1f TDF-3TC-EFV SQL\n Clients given 1f regimen during reporting period\n \n 2020-07-18 19:58:37 UTC\n \n 2020-07-19 01:56:13 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 777\n select o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere o.concept_id = 2250 and o.value_coded = 2207 \n and o.location_id =:location or parent_location =:location \n and o.obs_datetime between :startDate and :endDate \n and o.voided = 0 \n and o.person_id in ( \n select oss.person_id \n from obs oss \n where oss.obs_datetime BETWEEN :startDate AND :endDate \n and oss.concept_id = 4174 and oss.value_coded in (4175, 4243) \n )\n','2020-07-18 19:58:37',4,'2020-07-19 01:56:13',4,0,NULL,NULL,NULL,'48b7c7f2-0b24-4fcb-936a-3161ccb96809'),(778,'Clients Initiated SQL','Client who were newly initiated on ART during period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients Initiated SQL\n Client who were newly initiated on ART during period\n \n 2020-07-18 20:31:33 UTC\n \n 2020-07-18 20:39: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 778\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere o.concept_id = 2249 \n and date(o.value_datetime) between cast(:startDate as date) and cast(:endDate as date) \n and o.location_id = :location or parent_location = :location \n and o.voided = 0 \n and o.person_id not in ( \n select os.person_id from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n and os.obs_datetime between cast(:startDate as date) and cast(:endDate as date) \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 \n ) \n and o.person_id not in ( \n select os.person_id \n from obs os \n where os.concept_id = 4155 and os.value_coded = 2146 \n and os.obs_datetime between cast(:startDate as date) and cast(:endDate as date) \n )\n','2020-07-18 20:31:33',4,'2020-07-18 20:39:16',4,0,NULL,NULL,NULL,'58e7985e-69a0-4d49-846f-b9aff06675db'),(779,'CMP_ART Regimen 1month supply 1f','Active clients on ART given 1 month supply of 1f during the reporting period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1f\n Active clients on ART given 1 month supply of 1f during the reporting period\n \n 2020-07-19 01:31:05 UTC\n \n 2020-07-19 04: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 779\n Clients-newly-initiated-1f OR Clients-seen-given-1-month-supply-1f\n \n \n Clients-newly-initiated-1f\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 Clients-seen-given-1-month-supply-1f\n \n \n \n \n \n \n','2020-07-19 01:31:05',4,'2020-07-19 04:00:42',4,0,NULL,NULL,NULL,'1b85fc5a-285d-44ee-8d93-89823330461c'),(780,'CI07a: Adult 1st Line 1f=TDF-3TC-EFV 1month supply','Adults on 1st line 1f=TDF-3TC-EFV given 1month supply during the reporting period','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI07a: Adult 1st Line 1f=TDF-3TC-EFV 1month supply\n Adults on 1st line 1f=TDF-3TC-EFV given 1month supply during the reporting period\n \n 2020-07-19 01:41:26 UTC\n \n 2021-07-13 10:53: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 780\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-19 01:41:26',4,'2021-07-13 10:53:55',4,0,NULL,NULL,NULL,'266432b4-af8d-4c1f-9964-0e18df6a8ddb'),(781,'Clients seen given 1 month supply 1f','Clients seen for ART given 1 month supply of 1f regimen during period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1f\n Clients seen for ART given 1 month supply of 1f regimen during period\n \n 2020-07-19 03:54:29 UTC\n \n 2021-07-08 14:08:48 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 781\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2207)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-19 03:54:29',4,'2021-07-08 14:08:48',4,0,NULL,NULL,NULL,'aa28ce0b-63fd-424e-a559-32afafdf1bd4'),(782,'Clients given 3 months supply 1f','Clients seen given 3 months supply and those seen in previous months given 3 months supply for the reporting period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1f\n Clients seen given 3 months supply and those seen in previous months given 3 months supply for the reporting period\n \n 2020-07-19 04:12:20 UTC\n \n 2021-06-30 09:54:55 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 782\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2207)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-19 04:12:20',4,'2021-06-30 09:54:55',4,0,NULL,NULL,NULL,'08339268-81bc-4b91-860e-5fe9e69a96d9'),(783,'CMP_ART Regimen 3months supply 1f','Clients given 3 months supply of 1f regimen including Seen and Multi month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 3months supply 1f\n Clients given 3 months supply of 1f regimen including Seen and Multi month\n \n 2020-07-19 04:17:16 UTC\n \n 2020-07-19 04:18:45 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 783\n Clients-given-3-months-supply-1f\n \n \n Clients-given-3-months-supply-1f\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','2020-07-19 04:17:16',4,'2020-07-19 04:18:45',4,0,NULL,NULL,NULL,'3c34cfe7-e888-4dd5-8618-e0d0b3c0e7ec'),(784,'Clients given 6 months supply 1f','Clients seen given 6 months supply and those seen in previous months given 6 months supply for the reporting period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1f\n Clients seen given 6 months supply and those seen in previous months given 6 months supply for the reporting period\n \n 2020-07-19 04:31:40 UTC\n \n 2021-06-30 11: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 784\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2207)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-19 04:31:40',4,'2021-06-30 11:12:29',4,0,NULL,NULL,NULL,'a96d7239-75fc-49da-8fc2-e5de7f363b3a'); -INSERT INTO `serialized_object` VALUES (785,'Clients given Other months MMD supply 1f','Clients seen in current month given 2, 4, 5 or 7+ months supply and those seen in previous months given 2, 4, 5 or 7+ months supply for the reporting period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1f\n Clients seen in current month given 2, 4, 5 or 7+ months supply and those seen in previous months given 2, 4, 5 or 7+ months supply for the reporting period\n \n 2020-07-19 04:43:12 UTC\n \n 2021-06-30 11:42:53 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 785\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2207)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-19 04:43:12',4,'2021-06-30 11:42:53',4,0,NULL,NULL,NULL,'769c1abe-1bbd-44ad-8151-48df3b0e7d28'),(786,'CMP_ART Regimen 6months supply 1f','Clients given 6 months supply of 1f regimen including Seen and Multi month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 6months supply 1f\n Clients given 6 months supply of 1f regimen including Seen and Multi month\n \n 2020-07-19 04:46:50 UTC\n \n 2020-07-19 04:48:17 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 786\n Clients-given-6-months-supply-1f\n \n \n Clients-given-6-months-supply-1f\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','2020-07-19 04:46:50',4,'2020-07-19 04:48:17',4,0,NULL,NULL,NULL,'18e58639-4cfd-40bf-bf06-3599464b1473'),(787,'CMP_ART Regimen Other months MMD supply 1f','Clients given 2, 4 or 5 months supply of 1f regimen including Seen and Multi month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen Other months MMD supply 1f\n Clients given 2, 4 or 5 months supply of 1f regimen including Seen and Multi month\n \n 2020-07-19 04:49:08 UTC\n \n 2020-07-19 04:50:50 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 787\n Clients-given-Other-months-MMD-supply-1f\n \n \n Clients-given-Other-months-MMD-supply-1f\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','2020-07-19 04:49:08',4,'2020-07-19 04:50:50',4,0,NULL,NULL,NULL,'f95caefd-dc5f-4243-a75e-5e3e0b7911a0'),(788,'CI07b: Adult 1st Line 1f=TDF-3TC-EFV 3months supply','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI07b: Adult 1st Line 1f=TDF-3TC-EFV 3months supply\n \n \n 2020-07-19 06:18:10 UTC\n \n 2020-07-19 06:19:08 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 788\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-19 06:18:10',4,'2020-07-19 06:19:08',4,0,NULL,NULL,NULL,'780982cb-6a98-4775-8e76-9baa9d6b5f1b'),(789,'CI07c: Adult 1st Line 1f=TDF-3TC-EFV 6months supply','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI07c: Adult 1st Line 1f=TDF-3TC-EFV 6months supply\n \n \n 2020-07-19 06:20:27 UTC\n \n 2020-07-19 06:21:46 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 789\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-19 06:20:27',4,'2020-07-19 06:21:46',4,0,NULL,NULL,NULL,'e973976c-ca6a-4ac1-887a-2ebfe531a534'),(790,'CI07d: Adult 1st Line 1f=TDF-3TC-EFV Other (2, 4, 5 or 7+) MMD supply','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI07d: Adult 1st Line 1f=TDF-3TC-EFV Other (2, 4, 5 or 7+) MMD supply\n \n \n 2020-07-19 06:23:06 UTC\n \n 2020-07-21 01:48:17 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 790\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-19 06:23:06',4,'2020-07-21 01:48:17',4,0,NULL,NULL,NULL,'9ab8597a-486e-4d0f-ab75-7f113a29b08a'),(791,'Clients seen given 1 month supply 1c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1c\n \n \n 2020-07-20 03:19:19 UTC\n \n 2021-07-08 11:55:18 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 791\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2201)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:19:19',4,'2021-07-08 11:55:18',4,0,NULL,NULL,NULL,'af67b7bb-850e-4d7e-b736-07ccf3a76b09'),(792,'Clients given 3 months supply 1c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1c\n \n \n 2020-07-20 03:20:58 UTC\n \n 2021-06-30 09:51:24 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n endDateas\n \n java.util.Date\n true\n \n \n 792\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2201)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:20:58',4,'2021-06-30 09:51:24',4,0,NULL,NULL,NULL,'60b41494-8391-41e6-8f16-103bd95b4f44'),(793,'Clients given 6 months supply 1c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1c\n \n \n 2020-07-20 03:22:31 UTC\n \n 2021-06-30 11:05:32 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 793\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2201)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:22:31',4,'2021-06-30 11:05:32',4,0,NULL,NULL,NULL,'41a29f67-1b66-4614-86fb-d1f9a7f97bfb'),(794,'Clients given Other months MMD supply 1c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1c\n \n \n 2020-07-20 03:23:47 UTC\n \n 2021-06-30 11:37:55 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 794\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2201)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:23:47',4,'2021-06-30 11:37:55',4,0,NULL,NULL,NULL,'96c856a3-566e-4505-a448-160539293a28'),(795,'Clients seen given 1 month supply 1d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1d\n \n \n 2020-07-20 03:37:30 UTC\n \n 2021-07-08 11:57: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 795\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2203)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:37:30',4,'2021-07-08 11:57:56',4,0,NULL,NULL,NULL,'98353f43-868f-4509-ad15-37dc3adb0a1b'),(796,'Clients given 3 months supply 1d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1d\n \n \n 2020-07-20 03:39:17 UTC\n \n 2021-06-30 09:52:14 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 796\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2203)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:39:17',4,'2021-06-30 09:52:14',4,0,NULL,NULL,NULL,'069f81cf-1fa0-4367-83c8-0f3c20c42f85'),(797,'Clients given 6 months supply 1d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1d\n \n \n 2020-07-20 03:40:12 UTC\n \n 2021-06-30 11:07:24 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 797\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2203)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:40:12',4,'2021-06-30 11:07:24',4,0,NULL,NULL,NULL,'ea10a065-3af9-4102-a59b-5be824284852'),(798,'Clients given Other months MMD supply 1d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1d\n \n \n 2020-07-20 03:41:17 UTC\n \n 2021-06-30 11:41:47 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 798\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2203)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:41:17',4,'2021-06-30 11:41:47',4,0,NULL,NULL,NULL,'6c93540e-b083-41a9-9f17-a5ed6b921c72'),(799,'Clients seen given 1 month supply 1e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1e\n \n \n 2020-07-20 03:46:44 UTC\n \n 2021-07-08 11:58: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 799\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2205)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:46:44',4,'2021-07-08 11:58:20',4,0,NULL,NULL,NULL,'c7dd5c81-99f1-45fc-a84d-ec75465bd3d4'),(800,'Clients given 3 months supply 1e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1e\n \n \n 2020-07-20 03:47:32 UTC\n \n 2021-06-30 09:54:23 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 800\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2205)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:47:32',4,'2021-06-30 09:54:23',4,0,NULL,NULL,NULL,'e6b6c271-1dca-4432-bbaf-58d82c4f49da'),(801,'Clients given 6 months supply 1e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1e\n \n \n 2020-07-20 03:48:37 UTC\n \n 2021-06-30 11:11:57 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 801\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2205)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:48:37',4,'2021-06-30 11:11:57',4,0,NULL,NULL,NULL,'354b0335-23b3-48cc-8a95-c417fafcfc89'),(802,'Clients given Other months MMD supply 1e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1e\n \n \n 2020-07-20 03:49:41 UTC\n \n 2021-06-30 11:42:23 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 802\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2205)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:49:41',4,'2021-06-30 11:42:23',4,0,NULL,NULL,NULL,'e40f765b-16fd-4a32-b7a4-eede8841f1cf'),(803,'Clients seen given 1 month supply 1g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1g\n \n \n 2020-07-20 03:58:38 UTC\n \n 2021-07-08 14:09:31 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 803\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3672)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:58:38',4,'2021-07-08 14:09:31',4,0,NULL,NULL,NULL,'b3d8a75c-e786-4f83-8938-8af473c5953b'),(804,'Clients given 3 months supply 1g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1g\n \n \n 2020-07-20 04:00:16 UTC\n \n 2021-06-30 09:55:48 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 804\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3672)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:00:16',4,'2021-06-30 09:55:48',4,0,NULL,NULL,NULL,'ffc466dd-6ba0-4c8b-b843-200ea3d86bd2'),(805,'Clients given 6 months supply 1g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1g\n \n \n 2020-07-20 04:01:31 UTC\n \n 2021-06-30 11:14:32 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 805\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3672)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:01:31',4,'2021-06-30 11:14:32',4,0,NULL,NULL,NULL,'9062d6f9-de1a-4bd5-875c-6357ab622d92'),(806,'Clients given Other months MMD supply 1g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1g\n \n \n 2020-07-20 04:02:23 UTC\n \n 2021-06-30 11:43:38 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 806\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3672)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:02:23',4,'2021-06-30 11:43:38',4,0,NULL,NULL,NULL,'5e27d4a7-b843-4094-8f8e-c926f758e43a'),(807,'Clients seen given 1 month supply 1h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1h\n \n \n 2020-07-20 04:10:22 UTC\n \n 2021-07-08 14:10: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 807\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3673)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:10:22',4,'2021-07-08 14:10:03',4,0,NULL,NULL,NULL,'fe4a76e1-27ff-4dd1-b1e0-41906972b346'),(808,'Clients given 6 months supply 1h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1h\n \n \n 2020-07-20 04:12:36 UTC\n \n 2021-06-30 11:15:07 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 808\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3673)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:12:36',4,'2021-06-30 11:15:07',4,0,NULL,NULL,NULL,'04df1d42-9165-4fb9-bf72-5af4edeeb4b3'),(809,'Clients given 3 months supply 1h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1h\n \n \n 2020-07-20 04:13:53 UTC\n \n 2021-06-30 09:56:18 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 809\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3673)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:13:53',4,'2021-06-30 09:56:18',4,0,NULL,NULL,NULL,'b790398e-94da-443c-a2e6-f0d5a40b54c0'),(810,'Clients given Other months MMD supply 1h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1h\n \n \n 2020-07-20 04:17:17 UTC\n \n 2021-06-30 11:44:24 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 810\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3673)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:17:17',4,'2021-06-30 11:44:24',4,0,NULL,NULL,NULL,'d6cee7dc-26b3-47ee-9227-25aaf080d496'),(811,'Clients newly initiated 1j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1j\n \n \n 2020-07-20 04:25:32 UTC\n \n 2021-01-27 14:42:09 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 811\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4678 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 04:25:32',4,'2021-01-27 14:42:09',4,0,NULL,NULL,NULL,'9beae5ae-2e70-4911-9e5c-8b8472e9e035'),(812,'Clients seen given 1 month supply 1j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1j\n \n \n 2020-07-20 04:26:51 UTC\n \n 2021-07-08 11:06:54 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 812\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4678)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:26:51',4,'2021-07-08 11:06:54',4,0,NULL,NULL,NULL,'0be4efe7-801d-482d-ba8b-4d6b5fd33883'),(813,'Clients given 3 months supply 1j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1j\n \n \n 2020-07-20 04:28:15 UTC\n \n 2021-06-30 09:56:52 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 813\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4678)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:28:15',4,'2021-06-30 09:56:52',4,0,NULL,NULL,NULL,'15fad161-116e-42b3-b0a2-7649bce5addc'),(814,'Clients given 6 months supply 1j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1j\n \n \n 2020-07-20 04:29:15 UTC\n \n 2021-06-30 11:16:04 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 814\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4678)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:29:15',4,'2021-06-30 11:16:04',4,0,NULL,NULL,NULL,'23ae89c1-56ed-4bc5-9602-9d0d16b08c94'),(815,'Clients given Other months MMD supply 1j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1j\n \n \n 2020-07-20 04:30:02 UTC\n \n 2021-06-30 11:45:21 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 815\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4678)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:30:02',4,'2021-06-30 11:45:21',4,0,NULL,NULL,NULL,'ef251548-179f-46cf-9207-2cb47e47dbbc'),(816,'Clients newly initiated 1k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1k\n \n \n 2020-07-20 04:39:49 UTC\n \n 2021-01-27 14:43:48 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 816\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4679 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 04:39:49',4,'2021-01-27 14:43:48',4,0,NULL,NULL,NULL,'ffafa46e-8967-4ad9-9825-24337956bac5'),(817,'Clients seen given 1 month supply 1k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1k\n \n \n 2020-07-20 04:40:45 UTC\n \n 2021-07-08 14:11: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 817\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4679)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:40:45',4,'2021-07-08 14:11:07',4,0,NULL,NULL,NULL,'7685302a-4622-4230-be73-76868feec142'),(818,'Clients given 3 months supply 1k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1k\n \n \n 2020-07-20 04:42:09 UTC\n \n 2021-06-30 09:57:45 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 818\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4679)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:42:09',4,'2021-06-30 09:57:45',4,0,NULL,NULL,NULL,'196d200b-cd91-4bbd-acbb-4f016368cad8'),(819,'Clients given 6 months supply 1k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1k\n \n \n 2020-07-20 04:43:10 UTC\n \n 2021-06-30 11:16:48 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 819\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4679)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:43:10',4,'2021-06-30 11:16:48',4,0,NULL,NULL,NULL,'3fc19342-46e1-45af-94b5-e2c691cb69e4'),(820,'Clients given Other months MMD supply 1k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1k\n \n \n 2020-07-20 04:44:01 UTC\n \n 2021-06-30 11:46:02 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 820\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4679)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:44:01',4,'2021-06-30 11:46:02',4,0,NULL,NULL,NULL,'e6de45f1-6b8a-4436-ba97-b13059648def'),(821,'Clients newly initiated 1m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1m\n \n \n 2020-07-20 04:49:48 UTC\n \n 2021-01-27 14:44: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 821\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4680 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 04:49:48',4,'2021-01-27 14:44:29',4,0,NULL,NULL,NULL,'400c82ab-1ac9-4abe-af01-6eada8daf6e9'),(822,'Clients seen given 1 month supply 1m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1m\n \n \n 2020-07-20 04:50:41 UTC\n \n 2021-07-08 14:15: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 822\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4680)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:50:41',4,'2021-07-08 14:15:35',4,0,NULL,NULL,NULL,'9b8ae57c-2fef-42fd-bbad-b45c5e983226'),(823,'Clients given 3 months supply 1m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1m\n \n \n 2020-07-20 04:52:21 UTC\n \n 2021-06-30 09:58:16 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 823\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4680)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:52:21',4,'2021-06-30 09:58:16',4,0,NULL,NULL,NULL,'7dd2938b-6b42-45d4-a2cd-8a8624e1c42c'),(824,'Clients given 6 months supply 1m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1m\n \n \n 2020-07-20 04:52:59 UTC\n \n 2021-06-30 11:18:09 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 824\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4680)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:52:59',4,'2021-06-30 11:18:09',4,0,NULL,NULL,NULL,'bdd8854a-8e0d-4c16-8ccd-b2c0ac7e3fe7'),(825,'Clients given Other months MMD supply 1m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1m\n \n \n 2020-07-20 04:54:54 UTC\n \n 2021-06-30 11:46:37 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 825\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4680)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:54:54',4,'2021-06-30 11:46:37',4,0,NULL,NULL,NULL,'4ecbaa81-3f7c-46e5-834f-ddb6439039fc'),(826,'Clients newly initiated 1n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1n\n \n \n 2020-07-20 06:27:02 UTC\n \n 2021-01-27 14:47:42 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 826\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4681 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 06:27:02',4,'2021-01-27 14:47:42',4,0,NULL,NULL,NULL,'963f22d5-2068-4709-905b-3ec479ccde36'),(827,'Clients seen given 1 month supply 1n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1n\n \n \n 2020-07-20 06:29:10 UTC\n \n 2021-07-08 14:16:16 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 827\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4681)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:29:10',4,'2021-07-08 14:16:16',4,0,NULL,NULL,NULL,'2f27d810-0b99-43bb-818a-ac56ed6cc563'),(828,'Clients given 3 months supply 1n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1n\n \n \n 2020-07-20 06:30:01 UTC\n \n 2021-06-30 09:58:59 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 828\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4681)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:30:01',4,'2021-06-30 09:58:59',4,0,NULL,NULL,NULL,'16299f28-bb97-404c-992a-0ec5df3fd70e'),(829,'Clients given 6 months supply 1n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1n\n \n \n 2020-07-20 06:31:04 UTC\n \n 2021-06-30 11:20:58 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 829\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4681)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:31:04',4,'2021-06-30 11:20:58',4,0,NULL,NULL,NULL,'6978b1ca-2787-45ea-8552-0085b4948fdc'),(830,'Clients given Other months MMD supply 1n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1n\n \n \n 2020-07-20 06:31:57 UTC\n \n 2021-06-30 11:47:10 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 830\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4681)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:31:57',4,'2021-06-30 11:47:10',4,0,NULL,NULL,NULL,'db874a28-7767-4d91-8cd5-9e1dd5911ad6'),(831,'Clients newly initiated 1p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1p\n \n \n 2020-07-20 06:35:57 UTC\n \n 2021-01-27 14:48:48 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 831\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4682 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 06:35:57',4,'2021-01-27 14:48:48',4,0,NULL,NULL,NULL,'1ad60b6d-87fa-4d43-a8a6-3018aedfcd66'),(832,'Clients seen given 1 month supply 1p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1p\n \n \n 2020-07-20 06:36:55 UTC\n \n 2021-07-08 14:16: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 832\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4682)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:36:55',4,'2021-07-08 14:16:45',4,0,NULL,NULL,NULL,'173e906f-ba1c-43bb-9d48-f11d32ce0241'),(833,'Clients given 3 months supply 1p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1p\n \n \n 2020-07-20 06:38:16 UTC\n \n 2021-06-30 09:59:46 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 833\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4682)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:38:16',4,'2021-06-30 09:59:46',4,0,NULL,NULL,NULL,'64c658a4-cc2a-46b6-8831-5549e6d3e893'),(834,'Clients given 6 months supply 1p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1p\n \n \n 2020-07-20 06:39:07 UTC\n \n 2021-06-30 11:21:31 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 834\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4682)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:39:07',4,'2021-06-30 11:21:31',4,0,NULL,NULL,NULL,'753da82d-feaf-46d9-bcc5-f2b08f4bf1f7'),(835,'Clients given Other months MMD supply 1p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1p\n \n \n 2020-07-20 06:39:59 UTC\n \n 2021-06-30 11:48:00 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 835\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4682)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:39:59',4,'2021-06-30 11:48:00',4,0,NULL,NULL,NULL,'0f780026-4b19-47c2-b88a-f103b85b8493'),(836,'Clients newly initiated 1q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1q\n \n \n 2020-07-20 06:43:42 UTC\n \n 2021-01-27 14:50:00 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 836\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4683 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 06:43:42',4,'2021-01-27 14:50:00',4,0,NULL,NULL,NULL,'45f73eeb-68d7-442a-85b1-a2a3e5eacf79'),(837,'Clients seen given 1 month supply 1q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1q\n \n \n 2020-07-20 06:44:27 UTC\n \n 2021-07-08 14:17:36 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 837\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4683)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:44:27',4,'2021-07-08 14:17:36',4,0,NULL,NULL,NULL,'16822ce4-ed25-45cf-93e1-9d4de906c4c6'),(838,'Clients given 3 months supply 1q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1q\n \n \n 2020-07-20 06:45:34 UTC\n \n 2021-06-30 10:00:22 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 838\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4683)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:45:34',4,'2021-06-30 10:00:22',4,0,NULL,NULL,NULL,'1ed9b3ff-13e6-49eb-a21b-a3c588489a1b'),(839,'Clients given 6 months supply 1q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1q\n \n \n 2020-07-20 06:46:18 UTC\n \n 2021-06-30 11:23:53 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 839\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4683)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:46:18',4,'2021-06-30 11:23:53',4,0,NULL,NULL,NULL,'ebb33bdb-909b-4b87-a22e-b124d146291a'),(840,'Clients given Other months MMD supply 1q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1q\n \n \n 2020-07-20 06:47:11 UTC\n \n 2021-06-30 11:48:27 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 840\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4683)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:47:11',4,'2021-06-30 11:48:27',4,0,NULL,NULL,NULL,'ae410b11-acaa-425d-a309-7eb491cfa3eb'),(841,'Clients seen given 1 month supply 2c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2c\n \n \n 2020-07-20 06:53:36 UTC\n \n 2021-07-13 14:12: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 841\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2210)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:53:36',4,'2021-07-13 14:12:15',4,0,NULL,NULL,NULL,'c1f9e099-143c-4dd2-bfe0-8946fc5d148e'),(842,'Clients given 3 months supply 2c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2c\n \n \n 2020-07-20 06:54:57 UTC\n \n 2021-07-08 15:15:31 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 842\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 2210)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:54:57',4,'2021-07-08 15:15:31',4,0,NULL,NULL,NULL,'eca79239-2660-4146-ab21-53161a156d97'),(843,'Clients given 6 months supply 2c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2c\n \n \n 2020-07-20 06:55:39 UTC\n \n 2021-01-26 18:53:01 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 843\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 2210) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 2210) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 2210) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 2210) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 2210) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 2210) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 2210 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 06:55:39',4,'2021-01-26 18:53:01',4,0,NULL,NULL,NULL,'f408c2e1-4417-427b-ac7d-5bb0bce3656c'),(844,'Clients given Other months MMD supply 2c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2c\n \n \n 2020-07-20 06:57:41 UTC\n \n 2021-07-24 21:30:54 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 844\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2210)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:57:41',4,'2021-07-24 21:30:54',4,0,NULL,NULL,NULL,'986a2393-6ee9-4072-ae1d-04fd7b892a0d'),(845,'Clients seen given 1 month supply 2d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2d\n \n \n 2020-07-20 10:42:25 UTC\n \n 2021-07-13 14:14: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 845\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2209)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 10:42:25',4,'2021-07-13 14:14:04',4,0,NULL,NULL,NULL,'50d1da47-5c78-46f0-81dc-11c7eb0a2e60'),(846,'Clients given 3 months supply 2d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2d\n \n \n 2020-07-20 10:43:36 UTC\n \n 2021-07-14 08:13:38 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 846\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 2209)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 10:43:36',4,'2021-07-14 08:13:38',4,0,NULL,NULL,NULL,'2ab0d6c5-13ff-453d-98f2-c02b1eb59c41'),(847,'Clients given 6 months supply 2d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2d\n \n \n 2020-07-20 10:44:21 UTC\n \n 2021-01-26 18:57:10 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 847\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 2209) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 2209) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 2209) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 2209) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 2209) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 2209) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 2209 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 10:44:21',4,'2021-01-26 18:57:10',4,0,NULL,NULL,NULL,'99f90724-28b7-45c7-a73d-63d4d8f88dc0'),(848,'Clients given Other months MMD supply 2d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2d\n \n \n 2020-07-20 10:45:14 UTC\n \n 2021-07-24 21:31:27 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 848\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2209)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 10:45:14',4,'2021-07-24 21:31:27',4,0,NULL,NULL,NULL,'255083b1-80a9-41dd-8664-be91528a3d37'),(850,'Clients seen given 1 month supply 2e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2e\n \n \n 2020-07-20 12:24:17 UTC\n \n 2021-07-13 14:15:00 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 850\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3674)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 12:24:17',4,'2021-07-13 14:15:00',4,0,NULL,NULL,NULL,'226382c4-5c57-442d-ac94-dad96849df3b'),(851,'Clients given 3 months supply 2e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2e\n \n \n 2020-07-20 12:52:35 UTC\n \n 2021-07-14 08:14:33 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 851\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 3674)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 12:52:35',4,'2021-07-14 08:14:33',4,0,NULL,NULL,NULL,'69f7f4ee-f01a-433e-a758-8f616a3ff039'),(852,'Clients given 6 months supply 2e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2e\n \n \n 2020-07-20 12:54:03 UTC\n \n 2021-01-26 18:59:19 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 852\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3674) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 3674) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3674) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3674) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3674) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3674) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 3674 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 12:54:03',4,'2021-01-26 18:59:19',4,0,NULL,NULL,NULL,'cb6971ec-8888-4435-ae57-a6179afcdcb4'),(853,'Clients given Other months MMD supply 2e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2e\n \n \n 2020-07-20 12:54:40 UTC\n \n 2021-07-24 21:32:50 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 853\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3674)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 12:54:40',4,'2021-07-24 21:32:50',4,0,NULL,NULL,NULL,'204bc8e1-d480-469b-8e87-eeaf1842258b'),(854,'Clients seen given 1 month supply 2f','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2f\n \n \n 2020-07-20 13:01:49 UTC\n \n 2021-07-13 14:15:59 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 854\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3675)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:01:49',4,'2021-07-13 14:15:59',4,0,NULL,NULL,NULL,'c7c374df-995a-4c8e-b417-e9c71cd3798d'),(855,'Clients given 3 months supply 2f','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2f\n \n \n 2020-07-20 13:02:35 UTC\n \n 2021-07-14 08:15:05 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 855\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 3675)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:02:35',4,'2021-07-14 08:15:05',4,0,NULL,NULL,NULL,'15ced29c-f6a5-4742-beca-0f6367a97bca'); -INSERT INTO `serialized_object` VALUES (856,'Clients given 6 months supply 2f','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2f\n \n \n 2020-07-20 13:03:51 UTC\n \n 2021-01-26 19:00:50 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 856\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3675) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 3675) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3675) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3675) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3675) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3675) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 3675 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 13:03:51',4,'2021-01-26 19:00:50',4,0,NULL,NULL,NULL,'565bb065-69d1-4c09-9381-78b51e2f53bc'),(858,'Clients given Other months MMD supply 2f','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2f\n \n \n 2020-07-20 13:07:55 UTC\n \n 2021-07-24 21:33:24 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 858\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3675)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:07:55',4,'2021-07-24 21:33:24',4,0,NULL,NULL,NULL,'c2aaab49-9a28-4ac1-a9e7-58f87bcb3c00'),(859,'Clients seen given 1 month supply 2g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2g\n \n \n 2020-07-20 13:30:40 UTC\n \n 2021-07-13 14:16:33 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 859\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3676)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:30:40',4,'2021-07-13 14:16:33',4,0,NULL,NULL,NULL,'e09c5f28-85e5-4df9-970d-4e771a0a12fa'),(860,'Clients given 3 months supply 2g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2g\n \n \n 2020-07-20 13:31:29 UTC\n \n 2021-07-14 08:15:34 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 860\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 3676)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:31:29',4,'2021-07-14 08:15:34',4,0,NULL,NULL,NULL,'7a0140a1-1dac-4d2c-b23b-54bdbcdc3cfd'),(861,'Clients given 6 months supply 2g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2g\n \n \n 2020-07-20 13:32:15 UTC\n \n 2021-01-26 19:02:43 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 861\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3676) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 3676) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3676) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3676) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3676) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3676) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 3676 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 13:32:15',4,'2021-01-26 19:02:43',4,0,NULL,NULL,NULL,'563531db-dcac-42ed-aed1-6942a8d6adf0'),(862,'Clients given Other months MMD supply 2g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2g\n \n \n 2020-07-20 13:34:03 UTC\n \n 2021-07-24 21:33:49 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 862\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3676)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:34:03',4,'2021-07-24 21:33:49',4,0,NULL,NULL,NULL,'f4085fa1-d19d-4654-ab8a-5030eed896a7'),(863,'Clients seen given 1 month supply 2h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2h\n \n \n 2020-07-20 13:45:23 UTC\n \n 2021-07-13 14:17:29 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 863\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3677)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:45:23',4,'2021-07-13 14:17:29',4,0,NULL,NULL,NULL,'b4786a8b-fccd-4fe1-964f-70034909846f'),(864,'Clients given 3 months supply 2h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2h\n \n \n 2020-07-20 13:47:29 UTC\n \n 2021-07-14 08:16:40 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 864\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 3677)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:47:29',4,'2021-07-14 08:16:40',4,0,NULL,NULL,NULL,'4a6f7a2a-2166-487e-9add-7655727277ad'),(865,'Clients given 6 months supply 2h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2h\n \n \n 2020-07-20 13:48:11 UTC\n \n 2021-01-26 19:04:40 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 865\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3677) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 3677) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3677) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3677) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3677) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3677) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 3677 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 13:48:11',4,'2021-01-26 19:04:40',4,0,NULL,NULL,NULL,'2c4a733e-3851-4008-93d2-7e74cfec135b'),(866,'Clients given Other months MMD supply 2h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2h\n \n \n 2020-07-20 13:50:21 UTC\n \n 2021-07-24 21:34:22 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 866\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3677)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:50:21',4,'2021-07-24 21:34:22',4,0,NULL,NULL,NULL,'aebf1799-6b5c-4f7a-800a-6e1b8a35dfa8'),(867,'Clients newly initiated 2j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2j\n \n \n 2020-07-20 15:07:10 UTC\n \n 2021-01-27 15:03:46 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 867\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4689 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 15:07:10',4,'2021-01-27 15:03:46',4,0,NULL,NULL,NULL,'83f23b67-1231-4044-9152-c654f66ebe2e'),(868,'Clients seen given 1 month supply 2j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2j\n \n \n 2020-07-20 15:15:19 UTC\n \n 2021-07-13 14:18:45 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 868\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4689)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 15:15:19',4,'2021-07-13 14:18:45',4,0,NULL,NULL,NULL,'6a992088-7110-42bc-a8df-c65ed16cbdf4'),(869,'Clients given 3 months supply 2j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2j\n \n \n 2020-07-20 15:16:07 UTC\n \n 2021-07-14 08:17:46 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 869\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4689)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 15:16:07',4,'2021-07-14 08:17:46',4,0,NULL,NULL,NULL,'c55d654b-82b7-4426-bd0b-ac03347dbe35'),(870,'Clients given 6 months supply 2j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2j\n \n \n 2020-07-20 15:17:31 UTC\n \n 2021-01-26 19:17:47 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 870\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4689) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4689) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4689) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4689) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4689) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4689) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4689 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 15:17:31',4,'2021-01-26 19:17:47',4,0,NULL,NULL,NULL,'cf31032a-c3ae-4b18-99ae-7765a98e8937'),(871,'Clients given Other months MMD supply 2j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2j\n \n \n 2020-07-20 15:18:22 UTC\n \n 2021-07-24 21:34:55 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 871\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4689)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 15:18:22',4,'2021-07-24 21:34:55',4,0,NULL,NULL,NULL,'b7e4159b-8045-477b-b4d9-24083d1f4fa3'),(872,'Clients newly initiated 2k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2k\n \n \n 2020-07-20 15:29:14 UTC\n \n 2021-01-27 15:04:37 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 872\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4690 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 15:29:14',4,'2021-01-27 15:04:37',4,0,NULL,NULL,NULL,'8b592d42-c141-4d58-b770-d9c9fb2e7195'),(873,'Clients seen given 1 month supply 2k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2k\n \n \n 2020-07-20 15:30:52 UTC\n \n 2021-07-13 14:19:27 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 873\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4690)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 15:30:52',4,'2021-07-13 14:19:27',4,0,NULL,NULL,NULL,'8e0dd16c-a83c-48ba-80ba-0415119dbee4'),(874,'Clients given 3 months supply 2k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2k\n \n \n 2020-07-20 15:32:16 UTC\n \n 2021-07-14 08:18:19 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 874\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4690)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 15:32:16',4,'2021-07-14 08:18:19',4,0,NULL,NULL,NULL,'905f7e40-b853-43b9-a33a-5e2ff8d7874b'),(875,'Clients given 6 months supply 2k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2k\n \n \n 2020-07-20 15:34:06 UTC\n \n 2021-01-26 19:20:27 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 875\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4690) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4690) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4690) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4690) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4690) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4690) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4690 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 15:34:06',4,'2021-01-26 19:20:27',4,0,NULL,NULL,NULL,'1bd5f808-95a3-4645-b2d8-f4413fba1daa'),(876,'Clients given Other months MMD supply 2k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2k\n \n \n 2020-07-20 15:39:15 UTC\n \n 2021-07-24 22:06:18 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 876\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4690)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 15:39:15',4,'2021-07-24 22:06:18',4,0,NULL,NULL,NULL,'4ba2760b-2cef-460e-871f-1b48021fd52a'),(877,'Clients newly initiated 2l','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2l\n \n \n 2020-07-20 16:16:10 UTC\n \n 2021-01-27 15:05:15 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 877\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4691 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 16:16:10',4,'2021-01-27 15:05:15',4,0,NULL,NULL,NULL,'72c7972e-21fb-43b5-84cf-059dd3c33a1f'),(878,'Clients seen given 1 month supply 2l','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2l\n \n \n 2020-07-20 16:16:59 UTC\n \n 2021-07-13 14:20:06 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 878\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4691)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:16:59',4,'2021-07-13 14:20:06',4,0,NULL,NULL,NULL,'988f14b7-3565-4440-af9f-cb44508a59ce'),(879,'Clients given 3 months supply 2l','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2l\n \n \n 2020-07-20 16:18:06 UTC\n \n 2021-07-14 08:19:07 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 879\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4691)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:18:06',4,'2021-07-14 08:19:07',4,0,NULL,NULL,NULL,'f4580b03-d891-4203-a9c0-fcd1a8a78d14'),(880,'Clients given 6 months supply 2l','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2l\n \n \n 2020-07-20 16:19:25 UTC\n \n 2021-01-26 19:23:35 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 880\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4691) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4691) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4691) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4691) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4691) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4691) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4691 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 16:19:25',4,'2021-01-26 19:23:35',4,0,NULL,NULL,NULL,'e1198db3-509c-4c28-8495-b64378232599'),(881,'Clients given Other months MMD supply 2l','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2l\n \n \n 2020-07-20 16:20:39 UTC\n \n 2021-07-24 22:07:31 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 881\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4691)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:20:39',4,'2021-07-24 22:07:31',4,0,NULL,NULL,NULL,'f8cb3fb3-93ab-45d3-99a2-5f0e516de258'),(882,'Clients newly initiated 2m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2m\n \n \n 2020-07-20 16:25:28 UTC\n \n 2021-01-27 15:05:54 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 882\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4692 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 16:25:28',4,'2021-01-27 15:05:54',4,0,NULL,NULL,NULL,'7e35c205-e70c-43c8-ab26-e79255a149f1'),(883,'Clients seen given 1 month supply 2m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2m\n \n \n 2020-07-20 16:26:22 UTC\n \n 2021-07-13 14:20:38 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 883\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4692)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:26:22',4,'2021-07-13 14:20:38',4,0,NULL,NULL,NULL,'4d14334f-0967-4158-9449-38a640f94cc3'),(884,'Clients given 3 months supply 2m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2m\n \n \n 2020-07-20 16:27:47 UTC\n \n 2021-07-14 08:19:37 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 884\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4692)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:27:47',4,'2021-07-14 08:19:37',4,0,NULL,NULL,NULL,'cd30e227-46d5-4866-9c1f-a72e4ed6fdb9'),(885,'Clients given 6 months supply 2m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2m\n \n \n 2020-07-20 16:28:27 UTC\n \n 2021-01-26 19:24:35 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 885\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4692) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4692) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4692) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4692) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4692) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4692) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4692 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 16:28:27',4,'2021-01-26 19:24:35',4,0,NULL,NULL,NULL,'e193a848-d5e1-454a-8266-777440f7ad8d'),(886,'Clients given Other months MMD supply 2n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2n\n \n \n 2020-07-20 16:29:19 UTC\n \n 2021-07-24 22:08:52 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 886\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4693)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:29:19',4,'2021-07-24 22:08:52',4,0,NULL,NULL,NULL,'0a95aada-1316-4abe-b2aa-0b9dde51459f'),(887,'Clients given Other months MMD supply 2m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2m\n \n \n 2020-07-20 16:29:20 UTC\n \n 2021-07-24 22:08:24 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 887\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4692)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:29:20',4,'2021-07-24 22:08:25',4,0,NULL,NULL,NULL,'d341d266-1d27-4921-b731-8dc2ce13d82c'),(888,'Clients newly initiated 2n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2n\n \n \n 2020-07-20 16:33:51 UTC\n \n 2021-01-27 15:06:32 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 888\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4693 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 16:33:51',4,'2021-01-27 15:06:32',4,0,NULL,NULL,NULL,'a9066bb6-bf2a-4d22-9c9b-b22db43322f7'),(889,'Clients seen given 1 month supply 2n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2n\n \n \n 2020-07-20 16:34:42 UTC\n \n 2021-07-13 14:21:11 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 889\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4693)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:34:42',4,'2021-07-13 14:21:11',4,0,NULL,NULL,NULL,'c6422f72-825e-482d-a12d-73ab924f9528'),(890,'Clients given 3 months supply 2n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2n\n \n \n 2020-07-20 16:35:35 UTC\n \n 2021-07-14 08:20:08 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 890\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4693)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:35:35',4,'2021-07-14 08:20:08',4,0,NULL,NULL,NULL,'e0af83be-ad0e-48b9-9ee5-fff184acc985'),(891,'Clients given 6 months supply 2n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2n\n \n \n 2020-07-20 16:36:24 UTC\n \n 2021-01-26 19:27:24 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 891\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4693) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4693) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4693) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4693) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4693) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4693) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4693 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 16:36:24',4,'2021-01-26 19:27:24',4,0,NULL,NULL,NULL,'9a3d0805-b6f9-4eb2-9d05-5420deb24520'),(892,'Clients newly initiated 2o','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2o\n \n \n 2020-07-20 16:49:16 UTC\n \n 2021-01-27 15:07:14 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 892\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4694 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 16:49:16',4,'2021-01-27 15:07:14',4,0,NULL,NULL,NULL,'eb737a94-1eff-4a8b-82d4-d40159ea5817'),(893,'Clients seen given 1 month supply 2o','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2o\n \n \n 2020-07-20 16:50:04 UTC\n \n 2021-07-13 14:22:12 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 893\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4694)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:50:04',4,'2021-07-13 14:22:12',4,0,NULL,NULL,NULL,'52b8c228-c12b-4c0f-81fa-0027d615bd2a'),(894,'Clients given 3 months supply 2o','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2o\n \n \n 2020-07-20 16:51:01 UTC\n \n 2021-07-14 08:20:39 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 894\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4694)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:51:01',4,'2021-07-14 08:20:39',4,0,NULL,NULL,NULL,'69a5e670-44c6-47d9-acd8-6e12dfaa1d80'),(895,'Clients given 6 months supply 2o','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2o\n \n \n 2020-07-20 16:51:39 UTC\n \n 2021-01-26 19:29:32 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 895\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4694) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4694) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4694) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4694) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4694) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4694) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4694 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 16:51:39',4,'2021-01-26 19:29:32',4,0,NULL,NULL,NULL,'4622beff-06b0-46ff-9ffe-9e1a2e6a514f'),(896,'Clients given Other months MMD supply 2o','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2o\n \n \n 2020-07-20 16:52:33 UTC\n \n 2021-07-24 22:09:27 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 896\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4694)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:52:33',4,'2021-07-24 22:09:27',4,0,NULL,NULL,NULL,'34b88c09-e0c3-44b8-8cd2-a431099edd07'),(897,'Clients newly initiated 2p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2p\n \n \n 2020-07-20 16:56:58 UTC\n \n 2021-01-27 15:07:55 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 897\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4695 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 16:56:58',4,'2021-01-27 15:07:55',4,0,NULL,NULL,NULL,'3e67e8e3-a5eb-4cf7-b55b-ef75e74711c5'),(898,'Clients seen given 1 month supply 2p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2p\n \n \n 2020-07-20 16:57:50 UTC\n \n 2021-07-13 14:22:44 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 898\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4695)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:57:50',4,'2021-07-13 14:22:44',4,0,NULL,NULL,NULL,'48813e11-ba00-4da6-bf2f-3f11b709ce62'),(899,'Clients given 3 months supply 2p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2p\n \n \n 2020-07-20 16:58:45 UTC\n \n 2021-07-14 08:21:20 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 899\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4695)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:58:45',4,'2021-07-14 08:21:20',4,0,NULL,NULL,NULL,'1a682087-9f0a-45a2-8f0b-c8600f5c6c60'),(900,'Clients given 6 months supply 2p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2p\n \n \n 2020-07-20 17:00:01 UTC\n \n 2021-01-26 19:30:28 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 900\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4695) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4695) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4695) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4695) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4695) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4695) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4695 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 17:00:01',4,'2021-01-26 19:30:28',4,0,NULL,NULL,NULL,'3884fe84-f6b8-490c-a8fb-39733b570582'),(901,'Clients given Other months MMD supply 2p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2p\n \n \n 2020-07-20 17:00:44 UTC\n \n 2021-07-24 22:10:01 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 901\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4695)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 17:00:44',4,'2021-07-24 22:10:01',4,0,NULL,NULL,NULL,'4948619f-ed82-40ed-9da5-44a3ae4169f6'),(902,'Clients newly initiated 2q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2q\n \n \n 2020-07-20 17:03:30 UTC\n \n 2021-01-27 15:09:30 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 902\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4849 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 17:03:30',4,'2021-01-27 15:09:30',4,0,NULL,NULL,NULL,'1f60ad52-150b-4228-8089-9d440e8d0cde'),(903,'Clients seen given 1 month supply 2q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2q\n \n \n 2020-07-20 17:04:25 UTC\n \n 2021-07-13 14:23:27 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 903\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4849)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 17:04:25',4,'2021-07-13 14:23:27',4,0,NULL,NULL,NULL,'ae79b825-cb86-42e5-8953-011f6d9008cf'),(904,'Clients given 3 months supply 2q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2q\n \n \n 2020-07-20 17:05:14 UTC\n \n 2021-07-14 08:21:53 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 904\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4849)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 17:05:14',4,'2021-07-14 08:21:53',4,0,NULL,NULL,NULL,'1606909a-0ff0-4513-a260-b32ee03f4241'),(905,'Clients given 6 months supply 2q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2q\n \n \n 2020-07-20 17:06:30 UTC\n \n 2021-01-26 19:31:31 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 905\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4849) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4849) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4849) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4849) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4849) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4849) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4849 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 17:06:30',4,'2021-01-26 19:31:31',4,0,NULL,NULL,NULL,'fd6704c7-9485-4842-b91d-1ae58c3bb265'),(906,'Clients given Other months MMD supply 2q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2q\n \n \n 2020-07-20 17:07:20 UTC\n \n 2021-07-24 22:10:33 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 906\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4849)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 17:07:20',4,'2021-07-24 22:10:33',4,0,NULL,NULL,NULL,'851209e6-8b48-4ec2-8ee7-5d42839b0ddf'),(907,'Clients newly initiated 3d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 3d\n \n \n 2020-07-20 17:24:03 UTC\n \n 2021-01-27 15:21:39 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 907\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4706 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 17:24:03',4,'2021-01-27 15:21:39',4,0,NULL,NULL,NULL,'eb729dfc-4ee5-4de4-aa27-e81aab012d0a'),(908,'Clients newly initiated 3e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 3e\n \n \n 2020-07-20 17:24:57 UTC\n \n 2021-01-27 15:22:17 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 908\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4707 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 17:24:57',4,'2021-01-27 15:22:17',4,0,NULL,NULL,NULL,'1140c832-9daf-4dda-9256-227493e9fa4f'),(909,'Clients newly initiated 3f','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 3f\n \n \n 2020-07-20 17:26:42 UTC\n \n 2021-01-27 15:22:52 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 909\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4708 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 17:26:42',4,'2021-01-27 15:22:52',4,0,NULL,NULL,NULL,'cc49c25f-038c-40bd-8aaa-68be2a51c88b'),(910,'Clients newly initiated 3g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 3g\n \n \n 2020-07-20 17:27:50 UTC\n \n 2021-01-27 15:23:36 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 910\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4709 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 17:27:50',4,'2021-01-27 15:23:36',4,0,NULL,NULL,NULL,'b14d4af3-b58c-48d9-aa33-e0b35aa06d30'),(911,'Clients newly initiated 3h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 3h\n \n \n 2020-07-20 17:29:15 UTC\n \n 2021-01-27 15:24:37 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 911\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4710 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 17:29:15',4,'2021-01-27 15:24:37',4,0,NULL,NULL,NULL,'d8b0aecd-81dc-4d1b-badd-7949b611bd87'),(912,'CMP_ART Regimen 1month supply 1c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1c\n \n \n 2020-07-20 19:34:44 UTC\n \n 2020-07-20 19:36:45 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 912\n Clients-newly-initiated-1c OR Clients-seen-given-1-month-supply-1c\n \n \n Clients-newly-initiated-1c\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 Clients-seen-given-1-month-supply-1c\n \n \n \n \n \n \n','2020-07-20 19:34:44',4,'2020-07-20 19:36:45',4,0,NULL,NULL,NULL,'829aeaa7-cb64-4a49-a81b-a040fbe9c8cd'),(913,'CMP_ART Regimen 1month supply 1d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1d\n \n \n 2020-07-20 19:38:24 UTC\n \n 2020-07-20 19:40:12 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 913\n Clients-seen-given-1-month-supply-1d OR Clients-newly-initiated-1d-\n \n \n Clients-seen-given-1-month-supply-1d\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 Clients-newly-initiated-1d-\n \n \n \n \n \n \n','2020-07-20 19:38:24',4,'2020-07-20 19:40:12',4,0,NULL,NULL,NULL,'74bef2b6-1548-4408-a0d8-f06267b194cd'),(914,'CMP_ART Regimen 1month supply 1e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1e\n \n \n 2020-07-20 19:41:21 UTC\n \n 2020-07-20 19:43:07 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 914\n Clients-newly-initiated-1e OR Clients-seen-given-1-month-supply-1e\n \n \n Clients-newly-initiated-1e\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 Clients-seen-given-1-month-supply-1e\n \n \n \n \n \n \n','2020-07-20 19:41:21',4,'2020-07-20 19:43:07',4,0,NULL,NULL,NULL,'010de706-fc5b-46bc-af84-92e43b167718'),(915,'CMP_ART Regimen 1month supply 1g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1g\n \n \n 2020-07-20 19:43:21 UTC\n \n 2020-07-21 00:56:20 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 915\n Clients-newly-initiated-1g- OR Clients-seen-given-1-month-supply-1g\n \n \n Clients-newly-initiated-1g-\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 Clients-seen-given-1-month-supply-1g\n \n \n \n \n \n \n','2020-07-20 19:43:21',4,'2020-07-21 00:56:20',4,0,NULL,NULL,NULL,'57d7a749-47e3-468d-b861-77762886a260'),(916,'CMP_ART Regimen 1month supply 1h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1h\n \n \n 2020-07-21 00:56:37 UTC\n \n 2020-07-21 00:58:05 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 916\n Clients-newly-initiated-1h OR Clients-seen-given-1-month-supply-1h\n \n \n Clients-newly-initiated-1h\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 Clients-seen-given-1-month-supply-1h\n \n \n \n \n \n \n','2020-07-21 00:56:37',4,'2020-07-21 00:58:05',4,0,NULL,NULL,NULL,'dac9644e-de7d-4d01-842a-5e0bd3b04be6'),(917,'CMP_ART Regimen 1month supply 1j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1j\n \n \n 2020-07-21 00:58:23 UTC\n \n 2020-07-21 00:59:43 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 917\n Clients-seen-given-1-month-supply-1j OR Clients-newly-initiated-1j\n \n \n Clients-seen-given-1-month-supply-1j\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 Clients-newly-initiated-1j\n \n \n \n \n \n \n','2020-07-21 00:58:23',4,'2020-07-21 00:59:43',4,0,NULL,NULL,NULL,'6c85c1eb-bafe-4fcf-b839-ec9bac116397'); -INSERT INTO `serialized_object` VALUES (918,'CMP_ART Regimen 1month supply 1k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1k\n \n \n 2020-07-21 01:00:03 UTC\n \n 2020-07-21 01:01:26 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 918\n Clients-seen-given-1-month-supply-1k OR Clients-newly-initiated-1k\n \n \n Clients-seen-given-1-month-supply-1k\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 Clients-newly-initiated-1k\n \n \n \n \n \n \n','2020-07-21 01:00:03',4,'2020-07-21 01:01:26',4,0,NULL,NULL,NULL,'df97af0c-0e5c-4c03-ac17-6fd6989c9f52'),(919,'CMP_ART Regimen 1month supply 1m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1m\n \n \n 2020-07-21 01:01:47 UTC\n \n 2020-07-21 01:03:02 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 919\n Clients-seen-given-1-month-supply-1m OR Clients-newly-initiated-1m\n \n \n Clients-seen-given-1-month-supply-1m\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 Clients-newly-initiated-1m\n \n \n \n \n \n \n','2020-07-21 01:01:47',4,'2020-07-21 01:03:02',4,0,NULL,NULL,NULL,'c6314f22-4686-415a-9180-aec975e149b6'),(920,'CMP_ART Regimen 1month supply 1n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1n\n \n \n 2020-07-21 01:03:35 UTC\n \n 2020-07-21 01:04:49 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 920\n Clients-seen-given-1-month-supply-1n OR Clients-newly-initiated-1n\n \n \n Clients-seen-given-1-month-supply-1n\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 Clients-newly-initiated-1n\n \n \n \n \n \n \n','2020-07-21 01:03:35',4,'2020-07-21 01:04:49',4,0,NULL,NULL,NULL,'d63a7ee0-2c04-4c43-a559-420c2c5833d3'),(921,'CMP_ART Regimen 1month supply 1p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1p\n \n \n 2020-07-21 01:05:09 UTC\n \n 2020-07-21 01:06:57 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 921\n Clients-seen-given-1-month-supply-1p OR Clients-newly-initiated-1p\n \n \n Clients-seen-given-1-month-supply-1p\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 Clients-newly-initiated-1p\n \n \n \n \n \n \n','2020-07-21 01:05:09',4,'2020-07-21 01:06:57',4,0,NULL,NULL,NULL,'dd9f9e82-0406-47c8-a725-bd696fbc3c12'),(922,'CMP_ART Regimen 1month supply 1q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1q\n \n \n 2020-07-21 01:07:11 UTC\n \n 2020-07-21 01:08:27 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 922\n Clients-newly-initiated-1q OR Clients-seen-given-1-month-supply-1q\n \n \n Clients-newly-initiated-1q\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 Clients-seen-given-1-month-supply-1q\n \n \n \n \n \n \n','2020-07-21 01:07:11',4,'2020-07-21 01:08:27',4,0,NULL,NULL,NULL,'5db23287-5dac-4b0f-a298-f4b6b5280c83'),(923,'CI04a: Adult 1st Line 1month supply 1c','Adults on 1st line 1c given 1month supply during the reporting period','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI04a: Adult 1st Line 1month supply 1c\n Adults on 1st line 1c given 1month supply during the reporting period\n \n 2020-07-21 01:12:25 UTC\n \n 2021-07-13 10:51:25 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 923\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:12:25',4,'2021-07-13 10:51:25',4,0,NULL,NULL,NULL,'afc603fa-52eb-4575-b911-da59f667ab73'),(924,'CI04b: Adult 1st Line 3 months supply 1c','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI04b: Adult 1st Line 3 months supply 1c\n \n \n 2020-07-21 01:15:26 UTC\n \n 2020-07-21 01:16:56 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 924\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:15:26',4,'2020-07-21 01:16:56',4,0,NULL,NULL,NULL,'7ac59930-19d9-4d19-bd11-c5053a450a26'),(925,'CI04c: Adult 1st Line 6 months supply 1c','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI04c: Adult 1st Line 6 months supply 1c\n \n \n 2020-07-21 01:17:44 UTC\n \n 2020-07-21 01:18:44 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 925\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:17:44',4,'2020-07-21 01:18:44',4,0,NULL,NULL,NULL,'62bc19a6-55a7-42af-b32d-bc3922ccada1'),(926,'CI04d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1c','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI04d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1c\n \n \n 2020-07-21 01:20:02 UTC\n \n 2020-07-21 01:21:42 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 926\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:20:02',4,'2020-07-21 01:21:42',4,0,NULL,NULL,NULL,'e47fb0fe-b9e3-441b-8750-3aeb6835425e'),(927,'CI05a: Adult 1st Line 1month supply 1d','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI05a: Adult 1st Line 1month supply 1d\n \n \n 2020-07-21 01:23:38 UTC\n \n 2021-07-13 10:52:30 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 927\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:23:38',4,'2021-07-13 10:52:30',4,0,NULL,NULL,NULL,'5a9ccea7-0a17-4507-93a1-1c065039d658'),(928,'CI05b: Adult 1st Line 3 months supply 1d','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI05b: Adult 1st Line 3 months supply 1d\n \n \n 2020-07-21 01:25:51 UTC\n \n 2020-07-21 01:26:43 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 928\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:25:51',4,'2020-07-21 01:26:43',4,0,NULL,NULL,NULL,'f1b32cd7-2259-4d99-9f4e-807e1ee36198'),(929,'CI05c: Adult 1st Line 6 months supply 1d','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI05c: Adult 1st Line 6 months supply 1d\n \n \n 2020-07-21 01:27:34 UTC\n \n 2020-07-21 01:28:31 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 929\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:27:34',4,'2020-07-21 01:28:31',4,0,NULL,NULL,NULL,'397b18ba-7676-47d7-8b74-36fb553fce5a'),(930,'CI05d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1d','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI05d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1d\n \n \n 2020-07-21 01:29:44 UTC\n \n 2020-07-21 01:30:44 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 930\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:29:44',4,'2020-07-21 01:30:44',4,0,NULL,NULL,NULL,'f5ef0c56-b3d7-48f0-8edf-f86a9ce3a131'),(931,'CI06a: Adult 1st Line 1month supply 1e','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI06a: Adult 1st Line 1month supply 1e\n \n \n 2020-07-21 01:32:17 UTC\n \n 2021-07-13 10:53:24 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 931\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:32:17',4,'2021-07-13 10:53:24',4,0,NULL,NULL,NULL,'951db50d-c81e-4873-937c-ef24fd97341b'),(932,'CI06b: Adult 1st Line 3 months supply 1e','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI06b: Adult 1st Line 3 months supply 1e\n \n \n 2020-07-21 01:34:03 UTC\n \n 2020-07-21 01:35:29 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 932\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:34:03',4,'2020-07-21 01:35:29',4,0,NULL,NULL,NULL,'9e37c53c-e2f6-407b-98d8-74609842b178'),(933,'CI06c: Adult 1st Line 6 months supply 1e','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI06c: Adult 1st Line 6 months supply 1e\n \n \n 2020-07-21 01:36:59 UTC\n \n 2020-07-21 01:37:49 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 933\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:36:59',4,'2020-07-21 01:37:49',4,0,NULL,NULL,NULL,'1934b675-10f8-4a35-a937-146270fc115f'),(934,'CI06d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1e','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI06d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1e\n \n \n 2020-07-21 01:38:46 UTC\n \n 2020-07-21 01:39:52 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 934\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:38:46',4,'2020-07-21 01:39:52',4,0,NULL,NULL,NULL,'71cd4a88-5f58-4d9c-8580-fee04ddc08d9'),(935,'CI08a: Adult 1st Line 1month supply 1g','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI08a: Adult 1st Line 1month supply 1g\n \n \n 2020-07-21 01:51:34 UTC\n \n 2021-07-13 10:54:56 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 935\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:51:34',4,'2021-07-13 10:54:56',4,0,NULL,NULL,NULL,'a13ddfbe-eca2-491c-acc9-504634fa6d82'),(936,'CI08b: Adult 1st Line 3 months supply 1g','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI08b: Adult 1st Line 3 months supply 1g\n \n \n 2020-07-21 01:53:02 UTC\n \n 2020-07-21 01:53:51 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 936\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:53:02',4,'2020-07-21 01:53:51',4,0,NULL,NULL,NULL,'70995f20-ec52-4069-a33e-0c8dd9e98ab9'),(937,'CI08c: Adult 1st Line 6 months supply 1g','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI08c: Adult 1st Line 6 months supply 1g\n \n \n 2020-07-21 01:54:19 UTC\n \n 2020-07-21 01:55:25 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 937\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:54:19',4,'2020-07-21 01:55:25',4,0,NULL,NULL,NULL,'183b513c-124d-4e45-9a79-3051d09e2cc4'),(938,'CI08d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1g','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI08d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1g\n \n \n 2020-07-21 01:57:00 UTC\n \n 2020-07-21 01:58:00 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 938\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:57:00',4,'2020-07-21 01:58:00',4,0,NULL,NULL,NULL,'dcdbd00a-5102-4e52-af19-04ff1d36d0c7'),(939,'CI09a: Adult 1st Line 1month supply 1h','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI09a: Adult 1st Line 1month supply 1h\n \n \n 2020-07-21 02:25:29 UTC\n \n 2021-07-13 10:55:41 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 939\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:25:29',4,'2021-07-13 10:55:41',4,0,NULL,NULL,NULL,'616f1562-8733-4c9e-b6e2-87a17106acaf'),(940,'CI09b: Adult 1st Line 3 months supply 1h','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI09b: Adult 1st Line 3 months supply 1h\n \n \n 2020-07-21 02:26:56 UTC\n \n 2020-07-21 02:27:40 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 940\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:26:56',4,'2020-07-21 02:27:40',4,0,NULL,NULL,NULL,'06dbe648-2a96-4fe4-aff3-575e84f4315b'),(941,'CI09c: Adult 1st Line 6 months supply 1h','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI09c: Adult 1st Line 6 months supply 1h\n \n \n 2020-07-21 02:28:15 UTC\n \n 2020-07-21 02:28:58 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 941\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:28:15',4,'2020-07-21 02:28:58',4,0,NULL,NULL,NULL,'c581e381-1a36-4591-9dc2-a8f978b9ae49'),(942,'CI09d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1h','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI09d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1h\n \n \n 2020-07-21 02:29:36 UTC\n \n 2020-07-21 02:30:16 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 942\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:29:36',4,'2020-07-21 02:30:16',4,0,NULL,NULL,NULL,'4fb604a8-0527-4eaf-bbdd-1a099d145648'),(943,'CI10a: Adult 1st Line 1month supply 1j','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI10a: Adult 1st Line 1month supply 1j\n \n \n 2020-07-21 02:34:17 UTC\n \n 2021-07-08 11:09:31 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 943\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:34:17',4,'2021-07-08 11:09:31',4,0,NULL,NULL,NULL,'1f473c7d-8597-41b4-992b-7baa77ed4aca'),(944,'CI10b: Adult 1st Line 3 months supply 1j','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI10b: Adult 1st Line 3 months supply 1j\n \n \n 2020-07-21 02:45:28 UTC\n \n 2020-07-21 02:46:14 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 944\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:45:28',4,'2020-07-21 02:46:14',4,0,NULL,NULL,NULL,'13a0c750-2408-4cd2-b1df-d453f45e3a00'),(945,'CI10c: Adult 1st Line 6 months supply 1j','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI10c: Adult 1st Line 6 months supply 1j\n \n \n 2020-07-21 02:46:48 UTC\n \n 2020-07-21 02:47:40 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 945\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:46:48',4,'2020-07-21 02:47:40',4,0,NULL,NULL,NULL,'26dd119e-e715-4f92-91f5-ba0f369673d9'),(946,'CI10d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1j','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI10d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1j\n \n \n 2020-07-21 02:48:29 UTC\n \n 2020-07-21 02:49:06 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 946\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:48:29',4,'2020-07-21 02:49:06',4,0,NULL,NULL,NULL,'ca557633-3e4c-49ca-9462-ca58f8010d92'),(947,'CI11a: Adult 1st Line 1month supply 1k','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI11a: Adult 1st Line 1month supply 1k\n \n \n 2020-07-21 02:51:55 UTC\n \n 2021-07-13 10:49:34 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 947\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:51:55',4,'2021-07-13 10:49:34',4,0,NULL,NULL,NULL,'dc095e0e-2c62-4c56-972b-17a67263614b'),(948,'CI11b: Adult 1st Line 3 months supply 1k','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI11b: Adult 1st Line 3 months supply 1k\n \n \n 2020-07-21 02:53:36 UTC\n \n 2020-07-21 02:54:27 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 948\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:53:36',4,'2020-07-21 02:54:27',4,0,NULL,NULL,NULL,'e32caf13-d848-4e21-97fa-e89d9563f306'),(949,'CI11c: Adult 1st Line 6 months supply 1k','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI11c: Adult 1st Line 6 months supply 1k\n \n \n 2020-07-21 02:54:50 UTC\n \n 2020-07-21 02:55:35 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 949\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:54:50',4,'2020-07-21 02:55:35',4,0,NULL,NULL,NULL,'0e12fae3-e9e2-40b2-a849-12376cb478a2'),(950,'CI11d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1k','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI11d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1k\n \n \n 2020-07-21 02:56:26 UTC\n \n 2020-07-21 02:57:11 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 950\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:56:26',4,'2020-07-21 02:57:11',4,0,NULL,NULL,NULL,'24257a6a-1879-4dd8-bd3d-f058279e0207'),(951,'CI12a: Adult 1st Line 1month supply 1m','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI12a: Adult 1st Line 1month supply 1m\n \n \n 2020-07-21 03:00:02 UTC\n \n 2021-07-13 10:58:00 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 951\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:00:02',4,'2021-07-13 10:58:00',4,0,NULL,NULL,NULL,'0ef6adce-502f-47eb-8795-429caf1b23ae'),(952,'CI12b: Adult 1st Line 3 months supply 1m','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI12b: Adult 1st Line 3 months supply 1m\n \n \n 2020-07-21 03:01:23 UTC\n \n 2020-07-21 03:02:10 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 952\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:01:23',4,'2020-07-21 03:02:10',4,0,NULL,NULL,NULL,'bf47b708-0b0b-43d8-a05b-273cff29afea'),(953,'CI12c: Adult 1st Line 6 months supply 1m','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI12c: Adult 1st Line 6 months supply 1m\n \n \n 2020-07-21 03:02:37 UTC\n \n 2020-07-21 03:03:20 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 953\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:02:37',4,'2020-07-21 03:03:20',4,0,NULL,NULL,NULL,'d969925a-4cbd-42c0-bf1a-cb78639c24ae'),(954,'CI12d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1m','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI12d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1m\n \n \n 2020-07-21 03:03:46 UTC\n \n 2020-07-21 03:10:58 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 954\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:03:46',4,'2020-07-21 03:10:58',4,0,NULL,NULL,NULL,'7df200bd-d206-4346-8d1f-a4afe7c120e2'),(955,'CI13a: Adult 1st Line 1month supply 1n','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI13a: Adult 1st Line 1month supply 1n\n \n \n 2020-07-21 03:05:47 UTC\n \n 2021-07-13 11:00:35 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 955\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:05:47',4,'2021-07-13 11:00:35',4,0,NULL,NULL,NULL,'32ff69f7-5a24-4515-a13a-59a4c2a0ef5c'),(956,'CI13b: Adult 1st Line 3 months supply 1n','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI13b: Adult 1st Line 3 months supply 1n\n \n \n 2020-07-21 03:07:19 UTC\n \n 2020-07-21 03:08:06 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 956\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:07:19',4,'2020-07-21 03:08:06',4,0,NULL,NULL,NULL,'1309392d-c442-4929-926d-bb5fc0e707eb'),(957,'CI13c: Adult 1st Line 6 months supply 1n','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI13c: Adult 1st Line 6 months supply 1n\n \n \n 2020-07-21 03:08:41 UTC\n \n 2020-07-21 03:09:19 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 957\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:08:41',4,'2020-07-21 03:09:19',4,0,NULL,NULL,NULL,'5af5abae-803c-43d8-9afa-04f11ee98fb0'),(958,'CI13d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1n','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI13d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1n\n \n \n 2020-07-21 03:11:12 UTC\n \n 2020-07-21 03:11:52 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 958\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:11:12',4,'2020-07-21 03:11:52',4,0,NULL,NULL,NULL,'21233a7a-d6c5-493f-a2a0-9a03f786176b'),(959,'CI14a: Adult 1st Line 1month supply 1p','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI14a: Adult 1st Line 1month supply 1p\n \n \n 2020-07-21 03:13:17 UTC\n \n 2021-07-13 11:01:47 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 959\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:13:17',4,'2021-07-13 11:01:47',4,0,NULL,NULL,NULL,'16876004-32fb-4a96-a177-2d0a96e7a208'),(960,'CI14b: Adult 1st Line 3 months supply 1p','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI14b: Adult 1st Line 3 months supply 1p\n \n \n 2020-07-21 03:15:36 UTC\n \n 2020-07-21 03:16:23 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 960\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:15:36',4,'2020-07-21 03:16:23',4,0,NULL,NULL,NULL,'e7b8e8a4-f8ee-4a2e-81cd-d97f5e7ceb8b'),(961,'CI14c: Adult 1st Line 6 months supply 1p','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI14c: Adult 1st Line 6 months supply 1p\n \n \n 2020-07-21 03:16:49 UTC\n \n 2020-07-21 03:17:52 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 961\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:16:49',4,'2020-07-21 03:17:52',4,0,NULL,NULL,NULL,'4969a61b-0fdc-4c63-b686-ba7822cfb08d'),(962,'CI14d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1p','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI14d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1p\n \n \n 2020-07-21 03:18:27 UTC\n \n 2020-07-21 03:19:04 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 962\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:18:27',4,'2020-07-21 03:19:04',4,0,NULL,NULL,NULL,'c3e318e4-0469-415f-832e-44d5b5e714f2'),(963,'CI15a: Adult 1st Line 1month supply 1q','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI15a: Adult 1st Line 1month supply 1q\n \n \n 2020-07-21 03:19:49 UTC\n \n 2021-07-13 11:03:04 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 963\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:19:49',4,'2021-07-13 11:03:04',4,0,NULL,NULL,NULL,'fb000c62-ea24-41e4-8645-8b0c6da882af'),(964,'CI15b: Adult 1st Line 3 months supply 1q','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI15b: Adult 1st Line 3 months supply 1q\n \n \n 2020-07-21 03:20:53 UTC\n \n 2020-07-21 03:21:47 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 964\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:20:53',4,'2020-07-21 03:21:47',4,0,NULL,NULL,NULL,'7463cbbb-24b0-41ba-ab49-a9113892ede3'),(965,'CI15c: Adult 1st Line 6 months supply 1q','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI15c: Adult 1st Line 6 months supply 1q\n \n \n 2020-07-21 03:22:10 UTC\n \n 2020-07-21 03:23:13 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 965\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:22:10',4,'2020-07-21 03:23:13',4,0,NULL,NULL,NULL,'ab56677f-53c2-428f-9f0b-d275436fbeac'),(966,'CI15d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1q','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI15d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1q\n \n \n 2020-07-21 03:23:46 UTC\n \n 2020-07-21 03:24:21 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 966\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:23:46',4,'2020-07-21 03:24:21',4,0,NULL,NULL,NULL,'ee8d0792-83e6-4a75-9d29-880203b1d97f'),(967,'tests','1mnth 2c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n tests\n 1mnth 2c\n \n 2020-07-24 14:51:44 UTC\n \n 2020-07-24 14:52: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 967\n','2020-07-24 14:51:44',4,'2020-07-24 14:52:23',4,0,NULL,NULL,NULL,'36cc1013-4264-4c43-af7a-5c097f01d1bc'),(968,'CMP_ART Regimen 1month supply 2c','1mnth 2c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2c\n 1mnth 2c\n \n 2020-07-24 14:53:18 UTC\n \n 2020-07-24 15:00: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 968\n Clients-newly-initiated-2c OR Clients-seen-given-1-month-supply-2c\n \n \n Clients-newly-initiated-2c\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 Clients-seen-given-1-month-supply-2c\n \n \n \n \n \n \n','2020-07-24 14:53:18',4,'2020-07-24 15:00:26',4,0,NULL,NULL,NULL,'90455a27-26e1-4043-8199-8f7bda6f55da'),(969,'CMP_ART Regimen 1month supply 2d','1mnth 2d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2d\n 1mnth 2d\n \n 2020-07-24 15:01:04 UTC\n \n 2020-07-24 15:04: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 969\n Clients-newly-initiated-2d OR Clients-seen-given-1-month-supply-2d\n \n \n Clients-newly-initiated-2d\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 Clients-seen-given-1-month-supply-2d\n \n \n \n \n \n \n','2020-07-24 15:01:04',4,'2020-07-24 15:04:46',4,0,NULL,NULL,NULL,'4dbab0a2-b33e-4ed9-ae7d-1c4fd08fa665'),(970,'CMP_ART Regimen 1month supply 2e','1mnth 2e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2e\n 1mnth 2e\n \n 2020-07-24 15:05:29 UTC\n \n 2020-07-24 15:07: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 970\n Clients-newly-initiated-2e OR Clients-seen-given-1-month-supply-2e\n \n \n Clients-newly-initiated-2e\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 Clients-seen-given-1-month-supply-2e\n \n \n \n \n \n \n','2020-07-24 15:05:29',4,'2020-07-24 15:07:56',4,0,NULL,NULL,NULL,'c561c725-73b6-4ccf-a159-849c5fceee4d'),(971,'CMP_ART Regimen 1month supply 2f','1 mnth 2f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2f\n 1 mnth 2f\n \n 2020-07-24 15:08:32 UTC\n \n 2020-07-24 15: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 971\n Clients-newly-initiated-2f- OR Clients-seen-given-1-month-supply-2f\n \n \n Clients-newly-initiated-2f-\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 Clients-seen-given-1-month-supply-2f\n \n \n \n \n \n \n','2020-07-24 15:08:32',4,'2020-07-24 15:11:10',4,0,NULL,NULL,NULL,'7c9575bf-11fe-43d5-b643-6ad64139702c'),(972,'CMP_ART Regimen 1month supply 2g','1mnth 2g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2g\n 1mnth 2g\n \n 2020-07-24 15:12:42 UTC\n \n 2020-07-24 15:16: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 972\n Clients-newly-initiated-2g OR Clients-seen-given-1-month-supply-2g\n \n \n Clients-newly-initiated-2g\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 Clients-seen-given-1-month-supply-2g\n \n \n \n \n \n \n','2020-07-24 15:12:42',4,'2020-07-24 15:16:14',4,0,NULL,NULL,NULL,'f44d2ca7-dd58-414e-b2bb-0c25dfbcc2bf'),(973,'CMP_ART Regimen 1month supply 2h','1month 2h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2h\n 1month 2h\n \n 2020-07-24 15:17:06 UTC\n \n 2020-07-24 15: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 973\n Clients-newly-initiated-2g OR Clients-seen-given-1-month-supply-2h\n \n \n Clients-newly-initiated-2g\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 Clients-seen-given-1-month-supply-2h\n \n \n \n \n \n \n','2020-07-24 15:17:06',4,'2020-07-24 15:19:35',4,0,NULL,NULL,NULL,'c3fb524c-828b-4aa9-ad18-73c3afcd4b01'),(974,'CMP_ART Regimen 1month supply 2j','1month 2j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2j\n 1month 2j\n \n 2020-07-24 15:20:13 UTC\n \n 2020-07-24 15: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 974\n Clients-newly-initiated-2j OR Clients-seen-given-1-month-supply-2j\n \n \n Clients-newly-initiated-2j\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 Clients-seen-given-1-month-supply-2j\n \n \n \n \n \n \n','2020-07-24 15:20:13',4,'2020-07-24 15:25:05',4,0,NULL,NULL,NULL,'b1ab8586-4a72-4a16-b5d7-9482e6eae2fc'),(975,'CMP_ART Regimen 1month supply 2k','1mnth 2k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2k\n 1mnth 2k\n \n 2020-07-24 15:25:27 UTC\n \n 2020-07-24 15:30: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 975\n Clients-seen-given-1-month-supply-2k OR Clients-newly-initiated-2k\n \n \n Clients-seen-given-1-month-supply-2k\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 Clients-newly-initiated-2k\n \n \n \n \n \n \n','2020-07-24 15:25:27',4,'2020-07-24 15:30:29',4,0,NULL,NULL,NULL,'50c6447e-caa4-4ea4-8363-2959de4a7365'),(976,'CMP_ART Regimen 1month supply 2l','1mnth 2l','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2l\n 1mnth 2l\n \n 2020-07-24 15:30:56 UTC\n \n 2020-07-24 15:32: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 976\n Clients-seen-given-1-month-supply-2l OR Clients-newly-initiated-2l\n \n \n Clients-seen-given-1-month-supply-2l\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 Clients-newly-initiated-2l\n \n \n \n \n \n \n','2020-07-24 15:30:56',4,'2020-07-24 15:32:29',4,0,NULL,NULL,NULL,'872e6d0b-64c6-4ff1-a839-44dfc2bc7a9e'),(977,'CMP_ART Regimen 1month supply 2m','1mnth 2m','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2m\n 1mnth 2m\n \n 2020-07-26 06:13:53 UTC\n \n 2020-07-26 06:19: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 977\n Clients-seen-given-1-month-supply-2m OR Clients-newly-initiated-2m\n \n \n Clients-seen-given-1-month-supply-2m\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 Clients-newly-initiated-2m\n \n \n \n \n \n \n','2020-07-26 06:13:53',4,'2020-07-26 06:19:50',4,0,NULL,NULL,NULL,'d7dd8d8a-e3a1-472c-90fc-e0c450303c18'),(978,'CMP_ART Regimen 1month supply 2n','1mnth 2n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2n\n 1mnth 2n\n \n 2020-07-26 06:20:22 UTC\n \n 2020-07-26 06: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 978\n Clients-seen-given-1-month-supply-2n OR Clients-newly-initiated-2n\n \n \n Clients-seen-given-1-month-supply-2n\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 Clients-newly-initiated-2n\n \n \n \n \n \n \n','2020-07-26 06:20:22',4,'2020-07-26 06:24:10',4,0,NULL,NULL,NULL,'7f61ff5a-9a20-4b98-aea5-db7e27f4e2d2'),(979,'CMP_ART Regimen 1month supply 2o','1mnth 2o','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2o\n 1mnth 2o\n \n 2020-07-26 07:10:30 UTC\n \n 2020-07-26 07:14: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 979\n Clients-seen-given-1-month-supply-2o OR Clients-newly-initiated-2o\n \n \n Clients-seen-given-1-month-supply-2o\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 Clients-newly-initiated-2o\n \n \n \n \n \n \n','2020-07-26 07:10:30',4,'2020-07-26 07:14:11',4,0,NULL,NULL,NULL,'ba08340b-e00e-4de7-b5d7-8bee853471c0'),(980,'CMP_ART Regimen 1month supply 2p','1mnth 2p','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2p\n 1mnth 2p\n \n 2020-07-26 07:17:55 UTC\n \n 2020-07-26 07:36: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 980\n Clients-seen-given-1-month-supply-2p OR Clients-newly-initiated-2p\n \n \n Clients-seen-given-1-month-supply-2p\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 Clients-newly-initiated-2p\n \n \n \n \n \n \n','2020-07-26 07:17:55',4,'2020-07-26 07:36:10',4,0,NULL,NULL,NULL,'06709fce-50ff-4008-aec7-900443e2c2bc'),(981,'CMP_ART Regimen 1month supply 2q','1mnth 2q','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2q\n 1mnth 2q\n \n 2020-07-26 07:39:23 UTC\n \n 2020-07-26 07: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 981\n Clients-seen-given-1-month-supply-2q OR Clients-newly-initiated-2q\n \n \n Clients-seen-given-1-month-supply-2q\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 Clients-newly-initiated-2q\n \n \n \n \n \n \n','2020-07-26 07:39:23',4,'2020-07-26 07:42:14',4,0,NULL,NULL,NULL,'6d8b0fd8-70d9-4f09-8770-93a8a063bbbd'),(982,'2020_adult_arv_2ndline_regimen','new dataset adult 2nd line regimen','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_adult_arv_2ndline_regimen\n new dataset adult 2nd line regimen\n \n 2020-07-26 09:16:18 UTC\n \n 2020-07-26 09:16: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 982\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','2020-07-26 09:16:18',4,'2020-07-26 09:16:34',4,0,NULL,NULL,NULL,'8e5b796f-0a4c-4c90-af06-b3ef89810ef2'),(983,'2020_adult_arv_2ndline_regimen Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_adult_arv_2ndline_regimen Data Set\n \n 2020-07-26 09:16:34 UTC\n \n 2020-12-03 07:35: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 983\n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 2c1mnth\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_Age\n 15+yrs\n \n \n \n \n \n 2c3mnths\n \n \n \n \n \n \n \n \n \n 2d1mnth\n \n \n \n \n \n \n \n \n \n 2d3mnths\n \n \n \n \n \n \n \n \n \n 2e1mnth\n \n \n \n \n \n \n \n \n \n 2e3mnths\n \n \n \n \n \n \n \n \n \n 2f1mnth\n \n \n \n \n \n \n \n \n \n 2f3mnths\n \n \n \n \n \n \n \n \n \n 2g1mnth\n \n \n \n \n \n \n \n \n \n 2g3mnths\n \n \n \n \n \n \n \n \n \n 2h1mnth\n \n \n \n \n \n \n \n \n \n 2h3mnths\n \n \n \n \n \n \n \n \n \n 2i1mnth\n \n \n \n \n \n \n \n \n \n 2i3mnths\n \n \n \n \n \n \n \n \n \n 2j1mnth\n \n \n \n \n \n \n \n \n \n 2j3mnths\n \n \n \n \n \n \n \n \n \n 2k1mnth\n \n \n \n \n \n \n \n \n \n 2k3mnths\n \n \n \n \n \n \n \n \n \n 2l1mnth\n \n \n \n \n \n \n \n \n \n 2l3mnths\n \n \n \n \n \n \n \n \n \n 2m1mnth\n \n \n \n \n \n \n \n \n \n 2m3mnths\n \n \n \n \n \n \n \n \n \n 2n1mnth\n \n \n \n \n \n \n \n \n \n 2n3mnths\n \n \n \n \n \n \n \n \n \n 2o1mnth\n \n \n \n \n \n \n \n \n \n 2o3mnths\n \n \n \n \n \n \n \n \n \n 2p1mnth\n \n \n \n \n \n \n \n \n \n 2p3mnths\n \n \n \n \n \n \n \n \n \n 2q1mnth\n \n \n \n \n \n \n \n \n \n 2q3mnths\n \n \n \n \n \n \n \n \n \n 2r1mnth\n \n \n \n \n \n \n \n \n \n 2r3mnths\n \n \n \n \n \n \n \n \n \n 2s1mnth\n \n \n \n \n \n \n \n \n \n 2s3mnths\n \n \n \n \n \n \n \n \n \n','2020-07-26 09:16:34',4,'2020-12-03 07:35:24',4,0,NULL,NULL,NULL,'ef7a6344-1f91-4926-ba02-d45bbff8e6a6'),(985,'CMP_ART Regimen 1month supply 3b','1mnth 3b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 3b\n 1mnth 3b\n \n 2020-07-26 14:45:35 UTC\n \n 2020-07-30 10:21: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 985\n Clients-seen-given-1-month-supply-3b OR Clients-newly-initiated-3b\n \n \n Clients-seen-given-1-month-supply-3b\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 Clients-newly-initiated-3b\n \n \n \n \n \n \n','2020-07-26 14:45:35',4,'2020-07-30 10:21:37',4,0,NULL,NULL,NULL,'4ac8f9b1-b672-4687-a463-74a6806e4045'),(986,'CMP_ART Regimen 1month supply 3c','1mnth 3c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 3c\n 1mnth 3c\n \n 2020-07-26 14:52:06 UTC\n \n 2020-07-30 10:25: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 986\n Clients-newly-initiated-3c OR Clients-seen-given-1-month-supply-3c\n \n \n Clients-newly-initiated-3c\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 Clients-seen-given-1-month-supply-3c\n \n \n \n \n \n \n','2020-07-26 14:52:06',4,'2020-07-30 10:25:28',4,0,NULL,NULL,NULL,'759d2eb9-1dd6-4d76-865f-7cb1d6ef75cf'),(987,'CMP_ART Regimen 1month supply 3d','1mnth 3d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 3d\n 1mnth 3d\n \n 2020-07-26 14:56:17 UTC\n \n 2020-07-30 10:27: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 987\n Clients-newly-initiated-3d OR Clients-seen-given-1-month-supply-3d\n \n \n Clients-newly-initiated-3d\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 Clients-seen-given-1-month-supply-3d\n \n \n \n \n \n \n','2020-07-26 14:56:17',4,'2020-07-30 10:27:56',4,0,NULL,NULL,NULL,'3bfa5700-82fc-4e92-a9f1-84a2a2e5d098'),(988,'CMP_ART Regimen 1month supply 3e','1mnth 3e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 3e\n 1mnth 3e\n \n 2020-07-26 14:59:13 UTC\n \n 2020-07-30 10:30: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 988\n Clients-newly-initiated-3e OR Clients-seen-given-1-month-supply-3e\n \n \n Clients-newly-initiated-3e\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 Clients-seen-given-1-month-supply-3e\n \n \n \n \n \n \n','2020-07-26 14:59:13',4,'2020-07-30 10:30:08',4,0,NULL,NULL,NULL,'1a8828f4-337f-4563-9018-82d8df61b92c'),(989,'CMP_ART Regimen 1month supply 3f','1mnth 3f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 3f\n 1mnth 3f\n \n 2020-07-26 15:02:32 UTC\n \n 2020-07-30 10:32: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 989\n Clients-newly-initiated-3f OR Clients-seen-given-1-month-supply-3f\n \n \n Clients-newly-initiated-3f\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 Clients-seen-given-1-month-supply-3f\n \n \n \n \n \n \n','2020-07-26 15:02:32',4,'2020-07-30 10:32:56',4,0,NULL,NULL,NULL,'ccceead2-c7f3-4c50-b922-0e4566dc6c5f'),(990,'CMP_ART Regimen 1month supply 3g','1mnth 3g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 3g\n 1mnth 3g\n \n 2020-07-26 15:08:27 UTC\n \n 2020-07-30 10:34: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 990\n Clients-newly-initiated-3g OR Clients-seen-given-1-month-supply-3g\n \n \n Clients-newly-initiated-3g\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 Clients-seen-given-1-month-supply-3g\n \n \n \n \n \n \n','2020-07-26 15:08:27',4,'2020-07-30 10:34:43',4,0,NULL,NULL,NULL,'f036add2-8f10-4f62-a371-4afac2b81e97'),(991,'CMP_ART Regimen 1month supply 3h','1mnth 3h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 3h\n 1mnth 3h\n \n 2020-07-26 15:10:27 UTC\n \n 2020-07-30 10:36: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 991\n Clients-newly-initiated-3h OR Clients-seen-given-1-month-supply-3h\n \n \n Clients-newly-initiated-3h\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 Clients-seen-given-1-month-supply-3h\n \n \n \n \n \n \n','2020-07-26 15:10:27',4,'2020-07-30 10:36:16',4,0,NULL,NULL,NULL,'761cf953-a41c-45d1-bf0a-265a97685aee'),(992,'2020_adult_arv_3rdline_regimen','new dataset 3rdline ARV','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_adult_arv_3rdline_regimen\n new dataset 3rdline ARV\n \n 2020-07-26 15:13:37 UTC\n \n 2020-07-26 19:27: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 992\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','2020-07-26 15:13:37',4,'2020-07-26 19:27:44',4,0,NULL,NULL,NULL,'afe451d4-5080-4689-b64a-75f0211f81a3'),(993,'2020_adult_arv_2ndline_regimen Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_adult_arv_2ndline_regimen Data Set\n \n 2020-07-26 15:13:44 UTC\n \n 2020-07-26 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 993\n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 3a1mnth\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_Age\n 15+yrs\n \n \n \n \n \n 3b1mnth\n \n \n \n \n \n \n \n \n \n 3c1mnth\n \n \n \n \n \n \n \n \n \n 3d1mnth\n \n \n \n \n \n \n \n \n \n 3e1mnth\n \n \n \n \n \n \n \n \n \n 3f1mnth\n \n \n \n \n \n \n \n \n \n 3g1mnth\n \n \n \n \n \n \n \n \n \n 3h1mnth\n \n \n \n \n \n \n \n \n \n','2020-07-26 15:13:44',4,'2020-07-26 20:13:06',4,0,NULL,NULL,NULL,'01bbedc4-b494-4465-b5c8-cbaa75c5f0d5'),(994,'CMP_ART Regimen 1month supply 3a','1month 3a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 3a\n 1month 3a\n \n 2020-07-29 22:32:01 UTC\n \n 2020-07-30 09:52: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 994\n Clients-seen-given-1-month-supply-3a OR Clients-newly-initiated-3a\n \n \n Clients-seen-given-1-month-supply-3a\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 Clients-newly-initiated-3a\n \n \n \n \n \n \n','2020-07-29 22:32:01',4,'2020-07-30 09:52:26',4,0,NULL,NULL,NULL,'a7795190-fca8-4cc7-903c-ef70798e3763'),(995,'CI33a:Enrolled in Pre ART this month','pre ART enrolled','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI33a:Enrolled in Pre ART this month\n pre ART enrolled\n \n 2020-08-04 15:01:44 UTC\n \n 2020-08-04 15:06: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 995\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-08-04 15:01:44',4,'2020-08-04 15:06:11',4,0,NULL,NULL,NULL,'ff2143b3-5c22-4373-b026-e2ad9230d145'),(997,'CI33b: Clients ever enrolled on PrE ART','ever pre art','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI33b: Clients ever enrolled on PrE ART\n ever pre art\n \n 2020-08-04 16:10:56 UTC\n \n 2020-08-04 16:16: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 997\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-08-04 16:10:56',4,'2020-08-04 16:16:32',4,0,NULL,NULL,NULL,'63a41dcf-c43f-4143-a703-406e75e917bb'),(998,'CI34a: ART and Pre ART seen this month','care clients seen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI34a: ART and Pre ART seen this month\n care clients seen\n \n 2020-08-04 16:31:46 UTC\n \n 2020-08-04 16:58: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 998\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-08-04 16:31:46',4,'2020-08-04 16:58:48',4,0,NULL,NULL,NULL,'2dc3ab54-fb26-445c-a9f5-788588571414'),(999,'CI30a: ART and Pre ART screened for TB','ART and Pre ART screened for TB','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI30a: ART and Pre ART screened for TB\n ART and Pre ART screened for TB\n \n 2020-08-04 17:01:37 UTC\n \n 2020-08-04 17: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 999\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-08-04 17:01:37',4,'2020-08-04 17:02:59',4,0,NULL,NULL,NULL,'ff11b48e-496f-4399-a9ef-f10a6f8a1fe1'),(1002,'DM_Children_Age','Children Age Groups','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n DM_Children_Age\n Children Age Groups\n \n 2020-09-09 10:58:53 UTC\n \n 2020-09-09 11:06:02 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n 1002\n \n \n 01-04yrs\n \n \n \n \n maxAge\n 4\n \n \n minAge\n 1\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 05-09yrs\n \n \n \n \n maxAge\n 9\n \n \n minAge\n 5\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 10-14yrs\n \n \n \n \n maxAge\n 14\n \n \n minAge\n 10\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n Under 1yr\n \n \n \n \n maxAge\n 0\n \n \n minAge\n 0\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n','2020-09-09 12:58:53',4,'2020-09-09 13:06:02',4,0,NULL,NULL,NULL,'229c55ed-b8a7-4f88-b3b6-a0df413f524c'),(1004,'DM_Adults_Age','Adult Age Groups','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n DM_Adults_Age\n Adult Age Groups\n \n 2020-09-10 16:49:59 UTC\n \n 2020-09-10 16:56:40 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n 1004\n \n \n 121-200yrs\n \n \n \n \n maxAge\n 200\n \n \n minAge\n 121\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 15-19yrs\n \n \n \n \n maxAge\n 19\n \n \n minAge\n 15\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 20-24yrs\n \n \n \n \n maxAge\n 24\n \n \n minAge\n 20\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 25-29yrs\n \n \n \n \n maxAge\n 29\n \n \n minAge\n 25\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 30-34yrs\n \n \n \n \n maxAge\n 34\n \n \n minAge\n 30\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 35-39yrs\n \n \n \n \n maxAge\n 39\n \n \n minAge\n 35\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 40-44yrs\n \n \n \n \n maxAge\n 44\n \n \n minAge\n 40\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 45-49yrs\n \n \n \n \n maxAge\n 49\n \n \n minAge\n 45\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 50-120yrs\n \n \n \n \n maxAge\n 120\n \n \n minAge\n 50\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n','2020-09-10 18:49:59',4,'2020-09-10 18:56:40',4,0,NULL,NULL,NULL,'5c344e8a-2fd0-4dff-a4b4-48516c0298e3'),(1005,'DM_Finer_Age','Finer Age Groups','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n DM_Finer_Age\n Finer Age Groups\n \n 2020-09-10 16:59:10 UTC\n \n 2020-09-16 13:09:14 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n 1005\n \n \n 01-04yrs\n \n \n \n \n maxAge\n 4\n \n \n minAge\n 1\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 05-09yrs\n \n \n \n \n maxAge\n 9\n \n \n minAge\n 5\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 10-14yrs\n \n \n \n \n maxAge\n 14\n \n \n minAge\n 10\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 121-200yrs\n \n \n \n \n maxAge\n 200\n \n \n minAge\n 121\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 15-19yrs\n \n \n \n \n maxAge\n 19\n \n \n minAge\n 15\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 20-24yrs\n \n \n \n \n maxAge\n 24\n \n \n minAge\n 20\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 25-29yrs\n \n \n \n \n maxAge\n 29\n \n \n minAge\n 25\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 30-34yrs\n \n \n \n \n maxAge\n 34\n \n \n minAge\n 30\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 35-39yrs\n \n \n \n \n maxAge\n 39\n \n \n minAge\n 35\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 40-44yrs\n \n \n \n \n maxAge\n 44\n \n \n minAge\n 40\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 45-49yrs\n \n \n \n \n maxAge\n 49\n \n \n minAge\n 45\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 50Plus\n \n \n \n \n maxAge\n 120\n \n \n minAge\n 50\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n Under1yr\n \n \n \n \n maxAge\n 0\n \n \n minAge\n 0\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n','2020-09-10 18:59:10',4,'2020-09-16 15:09:14',4,0,NULL,NULL,NULL,'47af7610-5e91-4b2d-962d-0d317ffe03fb'),(1006,'2020_ART_Current',' ART CARE - NEW AND CURRENT NUMBER OF PERSONS STARTED ON ART','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_ART_Current\n ART CARE - NEW AND CURRENT NUMBER OF PERSONS STARTED ON ART\n \n 2020-09-16 12:53:38 UTC\n \n 2020-09-30 11: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 1006\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','2020-09-16 14:53:38',4,'2020-09-30 13:59:49',4,0,NULL,NULL,NULL,'f5608fc7-5bc6-49cc-a9b0-d52917f63cd2'),(1007,'2020_ART_Current Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_ART_Current Data Set\n \n 2020-09-16 12:53:44 UTC\n \n 2020-09-16 17:06: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 1007\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n DefaultF1-\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n DefaultF10\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n DefaultF15\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n DefaultF20\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n DefaultF25\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n DefaultF30\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n DefaultF35\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n DefaultF40\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n DefaultF45\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n DefaultF5-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n DefaultF50\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n DefaultF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n DefaultM1-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n DefaultM10\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n DefaultM15\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n DefaultM20\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n DefaultM25\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n DefaultM30\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n DefaultM35\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n DefaultM40\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n DefaultM45\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n DefaultM5-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n DefaultM50\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n DefaultM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n DiedClient\n \n \n \n \n \n \n \n \n \n LostToFU\n \n \n \n \n \n \n \n \n \n MMD_F1-4\n \n \n \n \n \n \n \n \n \n MMD_F10-14\n \n \n \n \n \n \n MMD_F15-19\n \n \n \n \n \n \n MMD_F20-24\n \n \n \n \n \n \n MMD_F25-29\n \n \n \n \n \n \n MMD_F30-34\n \n \n \n \n \n \n MMD_F35-39\n \n \n \n \n \n \n MMD_F40-44\n \n \n \n \n \n \n MMD_F45-49\n \n \n \n \n \n \n MMD_F5-9\n \n \n \n \n \n \n MMD_F50\n \n \n \n \n \n \n MMD_F<1\n \n \n \n \n \n \n MMD_M1-4\n \n \n \n \n \n \n MMD_M10-14\n \n \n \n \n \n \n MMD_M15-19\n \n \n \n \n \n \n MMD_M20-24\n \n \n \n \n \n \n MMD_M25-29\n \n \n \n \n \n \n MMD_M30-34\n \n \n \n \n \n \n MMD_M35-39\n \n \n \n \n \n \n MMD_M40-44\n \n \n \n \n \n \n MMD_M45-49\n \n \n \n \n \n \n MMD_M5-9\n \n \n \n \n \n \n MMD_M50\n \n \n \n \n \n \n MMD_M<1\n \n \n \n \n \n \n MissedF1-4\n \n \n \n \n \n \n \n \n \n MissedF10-\n \n \n \n \n \n \n MissedF15-\n \n \n \n \n \n \n MissedF20-\n \n \n \n \n \n \n MissedF25-\n \n \n \n \n \n \n MissedF30-\n \n \n \n \n \n \n MissedF35-\n \n \n \n \n \n \n MissedF40-\n \n \n \n \n \n \n MissedF45-\n \n \n \n \n \n \n MissedF5-9\n \n \n \n \n \n \n MissedF50\n \n \n \n \n \n \n MissedF<1\n \n \n \n \n \n \n MissedM1-4\n \n \n \n \n \n \n MissedM10-\n \n \n \n \n \n \n MissedM15-\n \n \n \n \n \n \n MissedM20-\n \n \n \n \n \n \n MissedM25-\n \n \n \n \n \n \n MissedM30-\n \n \n \n \n \n \n MissedM35-\n \n \n \n \n \n \n MissedM40-\n \n \n \n \n \n \n MissedM45-\n \n \n \n \n \n \n MissedM5-9\n \n \n \n \n \n \n MissedM50\n \n \n \n \n \n \n MissedM<1\n \n \n \n \n \n \n NewF1-4\n \n \n \n \n \n \n \n \n \n NewF10-14\n \n \n \n \n \n \n NewF15-19\n \n \n \n \n \n \n NewF20-24\n \n \n \n \n \n \n NewF25-29\n \n \n \n \n \n \n NewF30-34\n \n \n \n \n \n \n NewF35-39\n \n \n \n \n \n \n NewF40-44\n \n \n \n \n \n \n NewF45-49\n \n \n \n \n \n \n NewF5-9\n \n \n \n \n \n \n NewF50\n \n \n \n \n \n \n NewF<1\n \n \n \n \n \n \n NewM1-4\n \n \n \n \n \n \n NewM10-14\n \n \n \n \n \n \n NewM15-19\n \n \n \n \n \n \n NewM20-24\n \n \n \n \n \n \n NewM25-29\n \n \n \n \n \n \n NewM30-34\n \n \n \n \n \n \n NewM35-39\n \n \n \n \n \n \n NewM40-44\n \n \n \n \n \n \n NewM45-49\n \n \n \n \n \n \n NewM5-9\n \n \n \n \n \n \n NewM50\n \n \n \n \n \n \n NewM<1\n \n \n \n \n \n \n Restarted\n \n \n \n \n \n \n \n \n \n SeenF1-4\n \n \n \n \n \n \n \n \n \n SeenF10-14\n \n \n \n \n \n \n SeenF15-19\n \n \n \n \n \n \n SeenF20-24\n \n \n \n \n \n \n SeenF25-29\n \n \n \n \n \n \n SeenF30-34\n \n \n \n \n \n \n SeenF35-39\n \n \n \n \n \n \n SeenF40-44\n \n \n \n \n \n \n SeenF45-49\n \n \n \n \n \n \n SeenF5-9\n \n \n \n \n \n \n SeenF50\n \n \n \n \n \n \n SeenF<1\n \n \n \n \n \n \n SeenM1-4\n \n \n \n \n \n \n SeenM10-14\n \n \n \n \n \n \n SeenM15-19\n \n \n \n \n \n \n SeenM20-24\n \n \n \n \n \n \n SeenM25-29\n \n \n \n \n \n \n SeenM30-34\n \n \n \n \n \n \n SeenM35-39\n \n \n \n \n \n \n SeenM40-44\n \n \n \n \n \n \n SeenM45-49\n \n \n \n \n \n \n SeenM5-9\n \n \n \n \n \n \n SeenM50\n \n \n \n \n \n \n SeenM<1\n \n \n \n \n \n \n StoppedART\n \n \n \n \n \n \n \n \n \n TransferIn\n \n \n \n \n \n \n \n \n \n TransferOu\n \n \n \n \n \n \n \n \n \n','2020-09-16 14:53:44',4,'2020-09-16 19:06:19',4,0,NULL,NULL,NULL,'c84add35-e6ec-4ef4-81d3-53f3d0b7b38b'),(1008,'weight_query_updated','weights','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.NumericObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n weight_query_updated\n weights\n \n 2020-11-16 10:06:11 UTC\n \n 2020-11-17 12:17:11 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n value1\n \n java.lang.Double\n true\n \n \n value2\n \n java.lang.Double\n true\n \n \n 1008\n LAST\n \n \n \n \n \n GREATER_EQUAL\n LESS_THAN\n','2020-11-16 10:06:11',4,'2020-11-17 12:17:11',4,0,NULL,NULL,NULL,'59e2cda8-7991-4837-b0d0-a83f0fcbd8db'),(1009,'revised_child_weight','revised weight','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n revised_child_weight\n revised weight\n \n 2020-11-16 10:08:00 UTC\n \n 2020-11-20 10:06: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 1009\n \n \n 0-3.9kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 4.0\n \n \n value1\n 0.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n 10-13.9kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 14.0\n \n \n value1\n 10.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n 100+kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 120.0\n \n \n value1\n 100.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n 14-19.9kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 20.0\n \n \n value1\n 14.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n 20-24.9kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 25.0\n \n \n value1\n 20.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n 25-34.9kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 35.0\n \n \n value1\n 25.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n 35+kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 100.0\n \n \n value1\n 35.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n 35pluskg\n \n \n \n \n onOrBefore\n ${}\n \n \n value2\n 70.0\n \n \n value1\n 35.0\n \n \n onOrAfter\n ${}\n \n \n \n \n \n 4-5.9kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 6.0\n \n \n value1\n 4.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n 6-9.9kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 10.0\n \n \n value1\n 6.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n','2020-11-16 12:08:00',4,'2020-11-20 12:06:34',4,0,NULL,NULL,NULL,'e74d2f97-2a34-41e4-9ebd-e8ed8430bd7b'),(1010,'Children ARV Regimen_1stLine','Children ARV Regimen_1stLine','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\n Children ARV Regimen_1stLine\n \n 2020-11-16 11:27:59 UTC\n \n 2020-12-03 12: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 1010\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','2020-11-16 11:27:59',4,'2020-12-03 12:40:42',4,0,NULL,NULL,NULL,'369c2c45-a71a-48e6-bfe8-9edb1b962fe8'),(1011,'4h regimen testing Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4h regimen testing Data Set\n \n 2020-11-16 11:28:17 UTC\n \n 2021-02-04 08:45: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 1011\n \n \n revised_child_weight\n \n \n \n \n endDate\n ${endDate}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n Children_ages\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 4L0to3.9\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 revised_child_weight\n 0-3.9kg\n \n \n Children_ages\n Children 0to14\n \n \n \n \n \n 4L10to13.9\n \n \n \n \n revised_child_weight\n 10-13.9kg\n \n \n Children_ages\n Children 0to14\n \n \n \n \n \n 4L14to19.9\n \n \n \n \n revised_child_weight\n 14-19.9kg\n \n \n Children_ages\n Children 0to14\n \n \n \n \n \n 4L20to24.9\n \n \n \n \n revised_child_weight\n 20-24.9kg\n \n \n Children_ages\n Children 0to14\n \n \n \n \n \n 4L25to34.9\n \n \n \n \n revised_child_weight\n 25-34.9kg\n \n \n Children_ages\n Children 0to14\n \n \n \n \n \n 4L35plus\n \n \n \n \n revised_child_weight\n 35pluskg\n \n \n Children_ages\n Children 0to14\n \n \n \n \n \n 4L4to5.9\n \n \n \n \n revised_child_weight\n 4-5.9kg\n \n \n Children_ages\n Children 0to14\n \n \n \n \n \n 4L6to9.9\n \n \n \n \n revised_child_weight\n 6-9.9kg\n \n \n Children_ages\n Children 0to14\n \n \n \n \n \n 4c0to3.9\n \n \n \n \n \n \n \n \n \n 4c10to13.9\n \n \n \n \n \n \n 4c14to19.9\n \n \n \n \n \n \n 4c20to24.9\n \n \n \n \n \n \n 4c25to34.9\n \n \n \n \n \n \n 4c35plus\n \n \n \n \n \n \n 4c4to5.9\n \n \n \n \n \n \n 4c6to9.9\n \n \n \n \n \n \n 4d03to3.9\n \n \n \n \n \n \n \n \n \n 4d10to13.9\n \n \n \n \n \n \n 4d14to19.9\n \n \n \n \n \n \n 4d20to24.9\n \n \n \n \n \n \n 4d25to34.9\n \n \n \n \n \n \n 4d35plus\n \n \n \n \n \n \n 4d4to5.9\n \n \n \n \n \n \n 4d6to9.9\n \n \n \n \n \n \n 4e03to3.9\n \n \n \n \n \n \n \n \n \n 4e10to13.9\n \n \n \n \n \n \n 4e14to19.9\n \n \n \n \n \n \n 4e20to24.9\n \n \n \n \n \n \n 4e25to34.9\n \n \n \n \n \n \n 4e35plus\n \n \n \n \n \n \n 4e4to5.9\n \n \n \n \n \n \n 4e6to9.9\n \n \n \n \n \n \n 4f0to3.9\n \n \n \n \n \n \n \n \n \n 4f10to13.9\n \n \n \n \n \n \n 4f14to19.9\n \n \n \n \n \n \n 4f20to24.9\n \n \n \n \n \n \n 4f25to34.9\n \n \n \n \n \n \n 4f35plus\n \n \n \n \n \n \n 4f4to5.9\n \n \n \n \n \n \n 4f6to9.9\n \n \n \n \n \n \n 4g0to3.9\n \n \n \n \n \n \n \n \n \n 4g10to13.9\n \n \n \n \n \n \n 4g14to19.9\n \n \n \n \n \n \n 4g20to24.9\n \n \n \n \n \n \n 4g25to34.9\n \n \n \n \n \n \n 4g35plus\n \n \n \n \n \n \n 4g4to5.9\n \n \n \n \n \n \n 4g6to9.9\n \n \n \n \n \n \n 4h0to3.9\n \n \n \n \n \n \n \n \n \n 4h10to13.9\n \n \n \n \n \n \n 4h14to19.9\n \n \n \n \n \n \n 4h20to24.9\n \n \n \n \n \n \n 4h25to34.9\n \n \n \n \n \n \n 4h35plus\n \n \n \n \n \n \n 4h4to5.9\n \n \n \n \n \n \n 4h6to9.9\n \n \n \n \n \n \n 4j0to3.9\n \n \n \n \n \n \n \n \n \n 4j10to13.9\n \n \n \n \n \n \n 4j14to19.9\n \n \n \n \n \n \n 4j20to24.9\n \n \n \n \n \n \n 4j25to34.9\n \n \n \n \n \n \n 4j35plus\n \n \n \n \n \n \n 4j4to5.9\n \n \n \n \n \n \n 4j6to9.9\n \n \n \n \n \n \n 4k0to3.9\n \n \n \n \n \n \n \n \n \n 4k10to13.9\n \n \n \n \n \n \n 4k14to19.9\n \n \n \n \n \n \n 4k20to24.9\n \n \n \n \n \n \n 4k25to34.9\n \n \n \n \n \n \n 4k35plus\n \n \n \n \n \n \n 4k4to5.9\n \n \n \n \n \n \n 4k6to9.9\n \n \n \n \n \n \n','2020-11-16 11:28:17',4,'2021-02-04 08:45:06',4,0,NULL,NULL,NULL,'017e9c81-7e67-4b81-b9ac-9953c2d93f4b'),(1013,'4h regimen testing Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4h regimen testing Data Set\n \n 2020-11-16 11:29:47 UTC\n \n 2020-11-23 16: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 1013\n \n \n revised_child_weight\n \n \n \n \n endDate\n ${endDate}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n \n \n 4L0to3.9\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 revised_child_weight\n 0-3.9kg\n \n \n \n \n \n 4L10to13.9\n \n \n \n \n revised_child_weight\n 10-13.9kg\n \n \n \n \n \n 4L14to19.9\n \n \n \n \n revised_child_weight\n 14-19.9kg\n \n \n \n \n \n 4L20to24.9\n \n \n \n \n revised_child_weight\n 20-24.9kg\n \n \n \n \n \n 4L25to34.9\n \n \n \n \n revised_child_weight\n 25-34.9kg\n \n \n \n \n \n 4L35+kg\n \n \n \n \n revised_child_weight\n 35+kg\n \n \n \n \n \n 4L4to5.9\n \n \n \n \n revised_child_weight\n 4-5.9kg\n \n \n \n \n \n 4L6to9.9\n \n \n \n \n revised_child_weight\n 6-9.9kg\n \n \n \n \n \n 4c0to3.9\n \n \n \n \n \n \n \n \n \n 4c10to13.9\n \n \n \n \n \n \n 4c14to19.9\n \n \n \n \n \n \n 4c20to24.9\n \n \n \n \n \n \n 4c25to34.9\n \n \n \n \n \n \n 4c35+kg\n \n \n \n \n \n \n 4c4to5.9\n \n \n \n \n \n \n 4c6to9.9\n \n \n \n \n \n \n 4d0to3.9\n \n \n \n \n \n \n \n \n \n 4d10to13.9\n \n \n \n \n \n \n 4d14to19.9\n \n \n \n \n \n \n 4d20to24.9\n \n \n \n \n \n \n 4d25to34.9\n \n \n \n \n \n \n 4d35+kg\n \n \n \n \n \n \n 4d4to5.9\n \n \n \n \n \n \n 4d6to9.9\n \n \n \n \n \n \n 4e03to3.9\n \n \n \n \n \n \n \n \n \n 4e10to13.9\n \n \n \n \n \n \n 4e14to19.9\n \n \n \n \n \n \n 4e20to24.9\n \n \n \n \n \n \n 4e25to34.9\n \n \n \n \n \n \n 4e35+kg\n \n \n \n \n \n \n 4e4to5.9\n \n \n \n \n \n \n 4e6to9.9\n \n \n \n \n \n \n 4f0to3.9\n \n \n \n \n \n \n \n \n \n 4f10to13.9\n \n \n \n \n \n \n 4f14to19.9\n \n \n \n \n \n \n 4f20to24.9\n \n \n \n \n \n \n 4f25to34.9\n \n \n \n \n \n \n 4f35+kg\n \n \n \n \n \n \n 4f4to5.9\n \n \n \n \n \n \n 4f6to9.9\n \n \n \n \n \n \n 4g0to3.9\n \n \n \n \n \n \n \n \n \n 4g10to13.9\n \n \n \n \n \n \n 4g14to19.9\n \n \n \n \n \n \n 4g20to24.9\n \n \n \n \n \n \n 4g25to34.9\n \n \n \n \n \n \n 4g35+kg\n \n \n \n \n \n \n 4g4to5.9\n \n \n \n \n \n \n 4g6to9.9\n \n \n \n \n \n \n 4h0to3.9\n \n \n \n \n \n \n \n \n \n 4h10to13.9\n \n \n \n \n \n \n 4h14to19.9\n \n \n \n \n \n \n 4h20to24.9\n \n \n \n \n \n \n 4h25to34.9\n \n \n \n \n \n \n 4h35+kg\n \n \n \n \n \n \n 4h4to5.9\n \n \n \n \n \n \n 4h6to9.9\n \n \n \n \n \n \n 4j0to3.9\n \n \n \n \n \n \n \n \n \n 4j10to13.9\n \n \n \n \n \n \n 4j14to19.9\n \n \n \n \n \n \n 4j20to24.9\n \n \n \n \n \n \n 4j25to34.9\n \n \n \n \n \n \n 4j35+kg\n \n \n \n \n \n \n 4j4to5.9\n \n \n \n \n \n \n \n \n \n 4j6to9.9\n \n \n \n \n \n \n 4k0to3.9\n \n \n \n \n \n \n 4k10to13.9\n \n \n \n \n \n \n 4k14to19.9\n \n \n \n \n \n \n 4k20to24.9\n \n \n \n \n \n \n 4k25to34.9\n \n \n \n \n \n \n 4k35+kg\n \n \n \n \n \n \n 4k4to5.9\n \n \n \n \n \n \n 4k6to9.9\n \n \n \n \n \n \n','2020-11-16 13:29:47',4,'2020-11-23 18:20:12',4,0,NULL,NULL,NULL,'9f1d2576-51cf-452c-ab0f-b68c0cb2289f'),(1014,'adult_arv_2r_1mnth',' 1month supply of 2r','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2r_1mnth\n 1month supply of 2r\n \n 2020-11-20 11:48:38 UTC\n \n 2020-11-20 11:49:10 UTC\n \n \n location\n \n java.lang.String\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 1014\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4850 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-11-20 13:48:38',4,'2020-11-20 13:49:10',4,0,NULL,NULL,NULL,'fb71139e-a156-4964-a304-f80360ba200b'),(1015,'adult_arv_2r_3mnth','3mnths supply of 2r','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2r_3mnth\n 3mnths supply of 2r\n \n 2020-11-20 11:50:29 UTC\n \n 2020-12-02 19:51: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 1015\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4850 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-11-20 11:50:29',4,'2020-12-02 19:51:13',4,0,NULL,NULL,NULL,'8f18aeea-7884-4a10-9d05-85ae3c160bd0'),(1016,'Clients given 3 months supply 2r','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2r\n None\n \n 2020-11-20 11:52:23 UTC\n \n 2021-07-14 08: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 1016\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4850)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-11-20 11:52:23',4,'2021-07-14 08:22:25',4,0,NULL,NULL,NULL,'80905b89-7a28-4cda-a44b-25b0a291211d'),(1017,'Clients given 6 months supply 2r','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2r\n None\n \n 2020-11-20 11:55:09 UTC\n \n 2021-01-26 19:36: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 1017\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4850) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4850) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4850) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4850) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4850) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4850) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4850 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-11-20 11:55:09',4,'2021-01-26 19:36:05',4,0,NULL,NULL,NULL,'f81d3821-0b33-4721-8548-09089e951a1e'),(1018,'Clients given Other months MMD supply 2r','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2r\n None\n \n 2020-11-20 11:57:01 UTC\n \n 2021-07-24 23:08: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 1018\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4850)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-11-20 11:57:01',4,'2021-07-24 23:08:16',4,0,NULL,NULL,NULL,'ae3c1ee8-0e33-49bb-8c7f-2492ddd244da'),(1019,'Clients newly initiated 2r','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2r\n None\n \n 2020-11-20 12:01:14 UTC\n \n 2021-01-27 15:10: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 1019\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4850 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-11-20 12:01:14',4,'2021-01-27 15:10:26',4,0,NULL,NULL,NULL,'14abb047-bc53-4d1f-bee5-7c4112dad68d'),(1020,'Clients seen given 1 month supply 2r','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2r\n None\n \n 2020-11-20 12:03:07 UTC\n \n 2021-07-13 14:24: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 1020\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4850)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-11-20 12:03:07',4,'2021-07-13 14:24:13',4,0,NULL,NULL,NULL,'e4c0b8ee-d729-49d9-b05d-3af1aed9fe08'),(1021,'CMP_ART Regimen 1month supply 2r',' 1mnth 2r','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2r\n 1mnth 2r\n \n 2020-11-20 12:06:02 UTC\n \n 2020-12-03 10: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 1021\n Clients-seen-given-1-month-supply-2r OR Clients-newly-initiated-2r\n \n \n Clients-seen-given-1-month-supply-2r\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 Clients-newly-initiated-2r\n \n \n \n \n \n \n','2020-11-20 12:06:02',4,'2020-12-03 10:49:43',4,0,NULL,NULL,NULL,'5dc2d400-2d6f-4d68-bbdd-58f969efdee9'),(1022,'adult_arv_2s_1mnth',' 1month supply of 2s','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2s_1mnth\n 1month supply of 2s\n \n 2020-11-23 16:01:14 UTC\n \n 2020-11-23 16:01:33 UTC\n \n \n location\n \n java.lang.String\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 1022\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4851 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-11-23 18:01:14',4,'2020-11-23 18:01:33',4,0,NULL,NULL,NULL,'41b5c235-8f68-4765-9cb7-3052079b1e52'),(1023,'adult_arv_2s_3mnth',' 3mnths supply of 2s','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2s_3mnth\n 3mnths supply of 2s\n \n 2020-11-23 16:07:24 UTC\n \n 2020-12-02 19: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 1023\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4851 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-11-23 16:07:24',4,'2020-12-02 19:56:27',4,0,NULL,NULL,NULL,'e75199de-2b55-458d-ae92-fe19aae857bb'),(1024,'Clients given 3 months supply 2s','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2s\n None\n \n 2020-11-23 16:08:20 UTC\n \n 2021-07-14 08:22: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 1024\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4851)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-11-23 16:08:20',4,'2021-07-14 08:22:56',4,0,NULL,NULL,NULL,'b83fd0d2-7016-453c-8f4d-a5ab08ec00b0'),(1025,'Clients given 6 months supply 2s','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2s\n None\n \n 2020-11-23 16:09:50 UTC\n \n 2021-01-26 19:35: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 1025\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4851) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4851) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4851) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4851) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4851) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4851) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4851 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-11-23 16:09:50',4,'2021-01-26 19:35:14',4,0,NULL,NULL,NULL,'5de7880b-4de6-4770-923d-dc53c71bdd11'),(1026,'Clients given Other months MMD supply 2s','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2s\n None\n \n 2020-11-23 16:12:53 UTC\n \n 2021-07-24 23:11: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 1026\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4851)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-11-23 16:12:53',4,'2021-07-24 23:11:30',4,0,NULL,NULL,NULL,'9026be35-1eaf-4a05-aba3-c2dfffa9061e'),(1027,'Clients newly initiated 2s','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2s\n None\n \n 2020-11-23 16:14:46 UTC\n \n 2021-01-27 15:11: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 1027\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4851 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-11-23 16:14:46',4,'2021-01-27 15:11:07',4,0,NULL,NULL,NULL,'36ca3e4d-651f-4209-b140-480752765843'),(1028,'Clients seen given 1 month supply 2s','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2s\n None\n \n 2020-11-23 16:16:24 UTC\n \n 2021-07-13 14:24: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 1028\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4851)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-11-23 16:16:24',4,'2021-07-13 14:24:49',4,0,NULL,NULL,NULL,'48fdb859-4147-457e-8af6-3e2bf0ca1a0c'),(1029,'CMP_ART Regimen 1month supply 2s','1mnth 2s','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2s\n 1mnth 2s\n \n 2020-11-23 16:18:09 UTC\n \n 2020-11-23 16: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 1029\n Clients-seen-given-1-month-supply-2s OR Clients-newly-initiated-2s\n \n \n Clients-newly-initiated-2s\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 Clients-seen-given-1-month-supply-2s\n \n \n \n \n \n \n','2020-11-23 18:18:09',4,'2020-11-23 18:34:51',4,0,NULL,NULL,NULL,'a6720665-3d0b-4b70-b463-fb8c9e567d64'),(1030,'Clients given 3 months supply other ','other regimen supplied','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply other \n other regimen supplied\n \n 2020-11-30 21:17:21 UTC\n \n 2021-06-30 10:45: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 1030\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2143)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-11-30 21:17:21',4,'2021-06-30 10:45:45',4,0,NULL,NULL,NULL,'c28adf82-c0fb-446c-b3c2-101d4d4f146e'),(1031,'Clients given 3 months supply 2i','3mnths of 2i regimen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2i\n 3mnths of 2i regimen\n \n 2020-11-30 21:18:46 UTC\n \n 2021-07-14 08:17: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 1031\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 3678)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-11-30 21:18:46',4,'2021-07-14 08:17:08',4,0,NULL,NULL,NULL,'092b1af7-5dca-4b33-8a3f-98700da3548b'),(1036,'Clients given 3 months supply 3e','3mnths of 3e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 3e\n 3mnths of 3e\n \n 2020-11-30 21:27:28 UTC\n \n 2021-01-26 17: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 1036\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4707) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4707) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4707) \n \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4707 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-11-30 21:27:28',4,'2021-01-26 17:40:25',4,0,NULL,NULL,NULL,'b757ed79-c1de-4d4e-9d6d-c78202a81a4d'),(1037,'Clients given 3 months supply 3f','3mnths of 3f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 3f\n 3mnths of 3f\n \n 2020-11-30 21:28:58 UTC\n \n 2021-01-26 17:42: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 1037\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4708) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4708) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4708) \n \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4708 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-11-30 21:28:58',4,'2021-01-26 17:42:35',4,0,NULL,NULL,NULL,'34ca96df-ff64-4c2a-9ee3-6b25a5473382'),(1038,'Clients given 3 months supply 3g','3months of 3g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 3g\n 3months of 3g\n \n 2020-11-30 21:30:47 UTC\n \n 2021-01-26 17:44: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 1038\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4709) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4709) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4709) \n \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4709 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-11-30 21:30:47',4,'2021-01-26 17:44:05',4,0,NULL,NULL,NULL,'55dead5b-5fa0-434e-90df-16ff7a6923fb'),(1040,'Children ARV Regimen_2ndLine','2ndLine 0 to 14yrs','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\n 2ndLine 0 to 14yrs\n \n 2020-12-01 10:58:27 UTC\n \n 2020-12-01 12:40: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 1040\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','2020-12-01 12:58:27',4,'2020-12-01 14:40:44',4,0,NULL,NULL,NULL,'05a35dc8-35a8-4594-9194-0d4b6dd486d0'),(1041,'Children ARV Regimen_3rdLine 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 Data Set\n \n 2020-12-01 10:58:32 UTC\n \n 2020-12-01 12: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 1041\n \n \n revised_child_weight\n \n \n \n \n endDate\n ${endDate}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 5a03to3.9\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 revised_child_weight\n 0-3.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 5a04to5.9\n \n \n \n \n revised_child_weight\n 4-5.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 5a06to9.9\n \n \n \n \n revised_child_weight\n 6-9.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 5a10to13.9\n \n \n \n \n revised_child_weight\n 10-13.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 5a14to19.9\n \n \n \n \n revised_child_weight\n 14-19.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 5a20to24.9\n \n \n \n \n revised_child_weight\n 20-24.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 5a25to34.9\n \n \n \n \n revised_child_weight\n 25-34.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 5a35Plus\n \n \n \n \n revised_child_weight\n 35pluskg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 5b03to3.9\n \n \n \n \n \n \n \n \n \n 5b04to5.9\n \n \n \n \n \n \n 5b06to9.9\n \n \n \n \n \n \n 5b10to13.9\n \n \n \n \n \n \n 5b14to19.9\n \n \n \n \n \n \n 5b20to24.9\n \n \n \n \n \n \n 5b25to34.9\n \n \n \n \n \n \n 5b35Plus\n \n \n \n \n \n \n 5c03to3.9\n \n \n \n \n \n \n \n \n \n 5c04to5.9\n \n \n \n \n \n \n 5c06to9.9\n \n \n \n \n \n \n 5c10to13.9\n \n \n \n \n \n \n 5c14to19.9\n \n \n \n \n \n \n 5c20to24.9\n \n \n \n \n \n \n 5c25to34.9\n \n \n \n \n \n \n 5cPlus\n \n \n \n \n \n \n 5d03to3.9\n \n \n \n \n \n \n \n \n \n 5d04to5.9\n \n \n \n \n \n \n 5d06to9.9\n \n \n \n \n \n \n 5d10to13.9\n \n \n \n \n \n \n 5d14to19.9\n \n \n \n \n \n \n 5d20to24.9\n \n \n \n \n \n \n 5d25to34.9\n \n \n \n \n \n \n 5d35Plus\n \n \n \n \n \n \n 5e03to3.9\n \n \n \n \n \n \n \n \n \n 5e04to5.9\n \n \n \n \n \n \n 5e06to9.9\n \n \n \n \n \n \n 5e10to13.9\n \n \n \n \n \n \n 5e14to19.9\n \n \n \n \n \n \n 5e20to24.9\n \n \n \n \n \n \n 5e25to34.9\n \n \n \n \n \n \n 5e35Plus\n \n \n \n \n \n \n 5f03to3.9\n \n \n \n \n \n \n \n \n \n 5f04to5.9\n \n \n \n \n \n \n 5f06to9.9\n \n \n \n \n \n \n 5f10to13.9\n \n \n \n \n \n \n 5f14to19.9\n \n \n \n \n \n \n 5f20to24.9\n \n \n \n \n \n \n 5f25to34.9\n \n \n \n \n \n \n 5f35Plus\n \n \n \n \n \n \n 5g00to3.9\n \n \n \n \n \n \n \n \n \n 5g04to5.9\n \n \n \n \n \n \n 5g06to9.9\n \n \n \n \n \n \n 5g10to13.9\n \n \n \n \n \n \n 5g14to19.9\n \n \n \n \n \n \n 5g20to24.9\n \n \n \n \n \n \n 5g25to34.9\n \n \n \n \n \n \n 5g35Plus\n \n \n \n \n \n \n 5h00to3.9\n \n \n \n \n \n \n \n \n \n 5h04to5.9\n \n \n \n \n \n \n 5h06to9.9\n \n \n \n \n \n \n 5h10to13.9\n \n \n \n \n \n \n 5h14to19.9\n \n \n \n \n \n \n 5h20to24.9\n \n \n \n \n \n \n 5h25to34.9\n \n \n \n \n \n \n 5h35Plus\n \n \n \n \n \n \n','2020-12-01 12:58:32',4,'2020-12-01 14:01:44',4,0,NULL,NULL,NULL,'4af0c854-1dce-4ef5-a7cd-5317a534c373'),(1042,'Children ARV Regimen_3rdLine','3rdLine 0 to 14yrs','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\n 3rdLine 0 to 14yrs\n \n 2020-12-01 12:42:12 UTC\n \n 2020-12-01 12:42: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 1042\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','2020-12-01 14:42:12',4,'2020-12-01 14:42:17',4,0,NULL,NULL,NULL,'80ef520c-2d58-473a-a588-58b182a4dbcb'),(1043,'Children ARV Regimen_3rdLine 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 Data Set\n \n 2020-12-01 12:42:17 UTC\n \n 2020-12-01 13: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 1043\n \n \n revised_child_weight\n \n \n \n \n endDate\n ${endDate}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 6a03to3.9\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 revised_child_weight\n 0-3.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 6a04to5.9\n \n \n \n \n revised_child_weight\n 4-5.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 6a06to9.9\n \n \n \n \n revised_child_weight\n 6-9.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 6a10to13.9\n \n \n \n \n revised_child_weight\n 10-13.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 6a14to19.9\n \n \n \n \n revised_child_weight\n 14-19.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 6a20to24.9\n \n \n \n \n revised_child_weight\n 20-24.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 6a25to34.9\n \n \n \n \n revised_child_weight\n 25-34.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 6a35kgPlus\n \n \n \n \n revised_child_weight\n 35pluskg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 6b00to3.9\n \n \n \n \n \n \n \n \n \n 6b04to5.9\n \n \n \n \n \n \n 6b06to9.9\n \n \n \n \n \n \n 6b10to13.9\n \n \n \n \n \n \n 6b14to19.9\n \n \n \n \n \n \n 6b20to24.9\n \n \n \n \n \n \n 6b25to34.9\n \n \n \n \n \n \n 6b35kgPlus\n \n \n \n \n \n \n 6c00to3.9\n \n \n \n \n \n \n \n \n \n 6c04to5.9\n \n \n \n \n \n \n 6c06to9.9\n \n \n \n \n \n \n 6c10to13.9\n \n \n \n \n \n \n 6c14to19.9\n \n \n \n \n \n \n 6c20to24.9\n \n \n \n \n \n \n 6c25to34.9\n \n \n \n \n \n \n 6c35kgPlus\n \n \n \n \n \n \n 6d00to3.9\n \n \n \n \n \n \n \n \n \n 6d04to5.9\n \n \n \n \n \n \n 6d06to9.9\n \n \n \n \n \n \n 6d10to13.9\n \n \n \n \n \n \n 6d14to19.9\n \n \n \n \n \n \n 6d20to24.9\n \n \n \n \n \n \n 6d25to34.9\n \n \n \n \n \n \n 6d35kgPlus\n \n \n \n \n \n \n 6e00to3.9\n \n \n \n \n \n \n \n \n \n 6e04to5.9\n \n \n \n \n \n \n 6e06to9.9\n \n \n \n \n \n \n 6e10to13.9\n \n \n \n \n \n \n 6e14to19.9\n \n \n \n \n \n \n 6e20to24.9\n \n \n \n \n \n \n 6e25to34.9\n \n \n \n \n \n \n 6e35kgPlus\n \n \n \n \n \n \n 6f00to3.9\n \n \n \n \n \n \n \n \n \n 6f04to5.9\n \n \n \n \n \n \n 6f06to9.9\n \n \n \n \n \n \n 6f10to13.9\n \n \n \n \n \n \n 6f14to19.9\n \n \n \n \n \n \n 6f20to24.9\n \n \n \n \n \n \n 6f25to34.9\n \n \n \n \n \n \n 6f35kgPlus\n \n \n \n \n \n \n','2020-12-01 14:42:17',4,'2020-12-01 15:34:47',4,0,NULL,NULL,NULL,'6ef48774-47bc-4e3e-af6c-6a2b8d77c151'),(1044,'adult_arv_2r_1mnth','adult_arv_2r_1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2r_1mnth\n adult_arv_2r_1mnth\n \n 2020-12-02 17:17:57 UTC\n \n 2021-07-13 14:48: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 1044\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-12-02 17:17:57',4,'2021-07-13 14:48:20',4,0,NULL,NULL,NULL,'28807ad7-020c-4261-84e8-960017de0d3c'),(1045,'adult_arv_2s_3mnths','adult_arv_2s_3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2s_3mnths\n adult_arv_2s_3mnths\n \n 2020-12-02 17:26:50 UTC\n \n 2020-12-02 20:24: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 1045\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-12-02 17:26:50',4,'2020-12-02 20:24:28',4,0,NULL,NULL,NULL,'9508f75e-01d6-4fac-a9ef-701b6306f4e5'),(1046,'adult_arv_2r_3mnths','adult_arv_2r_3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2r_3mnths\n adult_arv_2r_3mnths\n \n 2020-12-02 17:31:00 UTC\n \n 2020-12-02 20:20: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 1046\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-12-02 17:31:00',4,'2020-12-02 20:20:01',4,0,NULL,NULL,NULL,'bcbafe45-287a-4341-8144-75a99f00c1e3'),(1047,'adult_arv_2s_1mnth','adult_arv_2s_1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2s_1mnth\n adult_arv_2s_1mnth\n \n 2020-12-02 20:45:08 UTC\n \n 2021-07-13 14:48: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 1047\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-12-02 20:45:08',4,'2021-07-13 14:48:35',4,0,NULL,NULL,NULL,'2de0ce41-df04-42e8-a72d-64902cad4a98'),(1048,'CMP_ART Regimen 1month supply 2i','CMP_ART Regimen 1month supply 2i','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2i\n CMP_ART Regimen 1month supply 2i\n \n 2020-12-02 20:46:49 UTC\n \n 2020-12-03 10:49: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 1048\n Clients-newly-initiated-2i OR Clients-seen-given-1-month-supply-2i\n \n \n Clients-newly-initiated-2i\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 Clients-seen-given-1-month-supply-2i\n \n \n \n \n \n \n','2020-12-02 20:46:49',4,'2020-12-03 10:49:09',4,0,NULL,NULL,NULL,'591d048c-3a90-49ac-837e-e10439b8fe82'),(1049,'Clients newly initiated 2i','Clients newly initiated 2i','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2i\n Clients newly initiated 2i\n \n 2020-12-02 20:51:46 UTC\n \n 2021-01-27 14:58: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 1049\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3678 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-12-02 20:51:46',4,'2021-01-27 14:58:29',4,0,NULL,NULL,NULL,'3c150559-79b5-49ac-890c-9d5f7a3a20fd'),(1050,'Clients seen given 1 month supply 2i','Clients seen given 1 month supply 2i','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2i\n Clients seen given 1 month supply 2i\n \n 2020-12-02 20:54:19 UTC\n \n 2021-07-13 14:18: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 1050\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3678)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-12-02 20:54:19',4,'2021-07-13 14:18:04',4,0,NULL,NULL,NULL,'baa39d83-3d61-46a8-9c06-28b1090d3b8f'),(1051,'adult_arv_2i_3mnths','adult_arv_2i_3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2i_3mnths\n adult_arv_2i_3mnths\n \n 2020-12-02 20:58:18 UTC\n \n 2020-12-02 21:01: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 1051\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-12-02 20:58:18',4,'2020-12-02 21:01:13',4,0,NULL,NULL,NULL,'417c4ce0-cb54-449e-ac98-8fc8e138f03d'),(1052,'adult_arv_2i_1mnth','adult_arv_2i_1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2i_1mnth\n adult_arv_2i_1mnth\n \n 2020-12-02 21:01:50 UTC\n \n 2021-07-13 14: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 1052\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-12-02 21:01:50',4,'2021-07-13 14:37:12',4,0,NULL,NULL,NULL,'2e956343-8dfb-46c3-94a6-c9c6f83959a6'),(1053,'Clients given 3 months supply 3a','Clients given 3 months supply 3a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 3a\n Clients given 3 months supply 3a\n \n 2021-01-26 17:32:43 UTC\n \n 2021-01-26 17:33: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 1053\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3683) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3683) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3683) \n \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3683 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-26 17:32:43',4,'2021-01-26 17:33:19',4,0,NULL,NULL,NULL,'bb3bfcea-7bf4-40ff-8e51-c02125d9ed36'),(1054,'Clients given 3 months supply 3b','3mnths 3b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 3b\n 3mnths 3b\n \n 2021-01-26 17:35:11 UTC\n \n 2021-01-26 17:35: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 1054\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3684) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3684) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3684) \n \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3684 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-26 17:35:11',4,'2021-01-26 17:35:48',4,0,NULL,NULL,NULL,'c961ad65-091a-4ef3-b3df-93795215d394'),(1055,'Clients given 3 months supply 3c','3mnths 3c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 3c\n 3mnths 3c\n \n 2021-01-26 17:36:24 UTC\n \n 2021-01-26 17:36: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 1055\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3685) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3685) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3685) \n \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3685 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-26 17:36:24',4,'2021-01-26 17:36:53',4,0,NULL,NULL,NULL,'980ee077-7ac1-4380-b636-b5d83e80e128'),(1056,'Clients given 3 months supply 3d','3mnths 3d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 3d\n 3mnths 3d\n \n 2021-01-26 17:38:04 UTC\n \n 2021-01-26 17:38: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 1056\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4706) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4706) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4706) \n \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4706 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-26 17:38:04',4,'2021-01-26 17:38:37',4,0,NULL,NULL,NULL,'a5671007-d60d-44f4-8e1c-230aeb2239ec'),(1057,'Clients given 3 months supply 3h','3 months 3h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 3h\n 3 months 3h\n \n 2021-01-26 17:44:47 UTC\n \n 2021-01-26 17:45: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 1057\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4710) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4710) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4710) \n \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4710 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-26 17:44:47',4,'2021-01-26 17:45:17',4,0,NULL,NULL,NULL,'2e7c12e2-5224-464a-b8be-3b2fd231a4e1'); -INSERT INTO `serialized_object` VALUES (1058,'Clients given 6 months supply 2i','6mnths 2i','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2i\n 6mnths 2i\n \n 2021-01-26 19:06:43 UTC\n \n 2021-01-26 19:07: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 1058\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3678) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 3678) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3678) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3678) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3678) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3678) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 3678 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-26 19:06:43',4,'2021-01-26 19:07:18',4,0,NULL,NULL,NULL,'826fa67b-2ba1-42de-bbc9-fff95007b9fb'),(1059,'Clients seen given 1 month supply other','1 month other','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply other\n 1 month other\n \n 2021-01-27 06:50:37 UTC\n \n 2021-07-08 14:19: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 1059\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2143)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-01-27 06:50:37',4,'2021-07-08 14:19:54',4,0,NULL,NULL,NULL,'aba0cb73-c297-4fba-b97d-89ac9a7c8003'),(1060,'Clients given 6 months supply other','6 months other','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply other\n 6 months other\n \n 2021-01-27 07:08:38 UTC\n \n 2021-06-30 11:24: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 1060\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2143)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-01-27 07:08:38',4,'2021-06-30 11:24:37',4,0,NULL,NULL,NULL,'2cbd2310-1aec-4bdf-b0e2-6a5387529764'),(1061,'Clients given Other months MMD supply other','other months other regimen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply other\n other months other regimen\n \n 2021-01-27 07:28:16 UTC\n \n 2021-06-30 11:49: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 1061\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2143)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-01-27 07:28:16',4,'2021-06-30 11:49:08',4,0,NULL,NULL,NULL,'c51f0308-5026-404c-afbf-35df5fb4e729'),(1062,'Clients newly initiated other regimen','initiated other','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated other regimen\n initiated other\n \n 2021-01-27 14:51:15 UTC\n \n 2021-01-27 14:51: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 1062\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2143 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2021-01-27 14:51:15',4,'2021-01-27 14:51:51',4,0,NULL,NULL,NULL,'83133cb9-2778-43d9-b579-1ad824027608'),(1063,'CMP_ART Regimen 1month supply other','compostion newly initiated and seen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply other\n compostion newly initiated and seen\n \n 2021-01-27 15:28:45 UTC\n \n 2021-01-27 15:32: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 1063\n Clients-seen-given-1-month-supply-other OR Clients-newly-initiated-other-regimen\n \n \n Clients-seen-given-1-month-supply-other\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 Clients-newly-initiated-other-regimen\n \n \n \n \n \n \n','2021-01-27 15:28:45',4,'2021-01-27 15:32:00',4,0,NULL,NULL,NULL,'60b6b073-1a42-4d55-b194-fadbb863aadc'),(1064,'Clients seen given 1 month supply 4g','4g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4g\n 4g\n \n 2021-01-27 21:09:12 UTC\n \n 2021-02-04 07:37: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 1064\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4684) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4684 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:09:12',4,'2021-02-04 07:37:42',4,0,NULL,NULL,NULL,'cfa78680-b638-40d6-bf8a-d6b3e7092725'),(1065,'Clients seen given 1 month supply 4h','4h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4h\n 4h\n \n 2021-01-27 21:10:56 UTC\n \n 2021-02-04 07:38: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 1065\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4685) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4685 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:10:56',4,'2021-02-04 07:38:29',4,0,NULL,NULL,NULL,'8c7bfe6d-17d0-4e79-836b-078e5fb4b7ba'),(1066,'Clients seen given 1 month supply 4j','4j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4j\n 4j\n \n 2021-01-27 21:12:51 UTC\n \n 2021-02-04 07:41: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 1066\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4686) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4686 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:12:51',4,'2021-02-04 07:41:48',4,0,NULL,NULL,NULL,'0d272d06-c49f-42c4-b238-961e4118287a'),(1067,'Clients seen given 1 month supply 4k','4k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4k\n 4k\n \n 2021-01-27 21:14:44 UTC\n \n 2021-02-04 07:42: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 1067\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4687) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4687 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:14:44',4,'2021-02-04 07:42:38',4,0,NULL,NULL,NULL,'358376fd-5341-4dcc-a010-914229961974'),(1068,'Clients seen given 1 month supply 4L','4L','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4L\n 4L\n \n 2021-01-27 21:16:30 UTC\n \n 2021-02-04 07:43: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 1068\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4688) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4688 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:16:30',4,'2021-02-04 07:43:43',4,0,NULL,NULL,NULL,'5450f823-8f45-49a7-b678-ab36e639003a'),(1069,'Clients seen given 1 month supply 5c','5c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 5c\n 5c\n \n 2021-01-27 21:26:07 UTC\n \n 2021-02-04 07:56: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 1069\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4696) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4696 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:26:07',4,'2021-02-04 07:56:53',4,0,NULL,NULL,NULL,'6c5f0b5e-d8e2-49a5-9add-ea65c07a8043'),(1070,'Clients seen given 1 month supply 5d','5d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 5d\n 5d\n \n 2021-01-27 21:29:58 UTC\n \n 2021-02-04 07:57: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 1070\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4697) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4697 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:29:58',4,'2021-02-04 07:57:57',4,0,NULL,NULL,NULL,'5420e208-15e9-46e3-a657-e923dc3f26be'),(1071,'Clients seen given 1 month supply 5e','5e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 5e\n 5e\n \n 2021-01-27 21:36:15 UTC\n \n 2021-02-04 08:06: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 1071\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4698) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4698 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:36:15',4,'2021-02-04 08:06:05',4,0,NULL,NULL,NULL,'5354f557-775e-4589-81ec-119d69b30474'),(1072,'Clients seen given 1 month supply 5f','5f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 5f\n 5f\n \n 2021-01-27 21:38:31 UTC\n \n 2021-02-04 08:08: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 1072\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4699) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4699 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:38:31',4,'2021-02-04 08:08:14',4,0,NULL,NULL,NULL,'e03d8077-1955-4529-a85b-f0e830a1bc5c'),(1073,'Clients seen given 1 month supply 5g','5g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 5g\n 5g\n \n 2021-01-27 21:40:02 UTC\n \n 2021-02-04 08:09: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 1073\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4700) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4700 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:40:02',4,'2021-02-04 08:09:12',4,0,NULL,NULL,NULL,'4a4bfccf-c6fe-4116-b6d4-53e56823c0be'),(1074,'Clients seen given 1 month supply 5h','5h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 5h\n 5h\n \n 2021-01-27 21:41:41 UTC\n \n 2021-02-04 08:10: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 1074\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4701) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4701 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:41:41',4,'2021-02-04 08:10:05',4,0,NULL,NULL,NULL,'270631db-3551-4e98-bae8-f69b16663145'),(1075,'Clients seen given 1 month supply 6b','6b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 6b\n 6b\n \n 2021-01-27 21:54:50 UTC\n \n 2021-02-04 08: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 1075\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3687) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3687 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:54:50',4,'2021-02-04 08:15:00',4,0,NULL,NULL,NULL,'99e92cc7-e9ff-4b77-8b8a-2a0f3f2531d8'),(1076,'Clients seen given 1 month supply 6c','6c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 6c\n 6c\n \n 2021-01-27 21:57:30 UTC\n \n 2021-02-04 08:16: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 1076\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4702) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4702 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:57:30',4,'2021-02-04 08:16:11',4,0,NULL,NULL,NULL,'1ba755ee-ec4a-4392-9d48-56e0e1e6f88c'),(1077,'Clients seen given 1 month supply 6d','6d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 6d\n 6d\n \n 2021-01-27 22:01:27 UTC\n \n 2021-02-04 08:17: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 1077\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4703) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4703 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 22:01:27',4,'2021-02-04 08:17:43',4,0,NULL,NULL,NULL,'e58406b7-fa8a-4b5c-ae40-3dddbb28b5f2'),(1078,'Clients seen given 1 month supply 6e','6e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 6e\n 6e\n \n 2021-01-27 22:03:20 UTC\n \n 2021-02-04 08:18: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 1078\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4704) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4704 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 22:03:20',4,'2021-02-04 08:18:35',4,0,NULL,NULL,NULL,'57d769e1-feb2-4a2f-b1ac-b3993f6a984a'),(1079,'Clients seen given 1 month supply 6f','6f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 6f\n 6f\n \n 2021-01-27 22:04:47 UTC\n \n 2021-02-04 08: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 1079\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4705) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4705 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 22:04:47',4,'2021-02-04 08:19:20',4,0,NULL,NULL,NULL,'da18d6ab-b020-450f-b2bd-39e1f9f74ba0'),(1080,'CMP_ART Regimen 1month supply 4L','4L','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4L\n 4L\n \n 2021-01-28 01:48:55 UTC\n \n 2021-01-28 01:51: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 1080\n Clients-newly-initiated-4L OR Clients-seen-given-1-month-supply-4L\n \n \n Clients-newly-initiated-4L\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 Clients-seen-given-1-month-supply-4L\n \n \n \n \n \n \n','2021-01-28 01:48:55',4,'2021-01-28 01:51:38',4,0,NULL,NULL,NULL,'488bcaf1-af5e-47ff-84a0-8274f96ccb1d'),(1081,'Clients given 4c','All Clients given 4c, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4c\n All Clients given 4c, Seen and MMD\n \n 2021-07-01 09:22:29 UTC\n \n 2021-07-14 09:17: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 1081\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:22:29',4,'2021-07-14 09:17:24',4,0,NULL,NULL,NULL,'9938e191-eb7a-40b5-bb9d-76dde26372f7'),(1082,'Clients given 4d',' All Clients given 4d, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4d\n All Clients given 4d, Seen and MMD\n \n 2021-07-01 09:25:51 UTC\n \n 2021-07-14 09:19: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 1082\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:25:51',4,'2021-07-14 09:19:05',4,0,NULL,NULL,NULL,'8292e011-c883-47e2-8632-c9978c45eca8'),(1083,'Clients given 4e','All Clients given 4e, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4e\n All Clients given 4e, Seen and MMD\n \n 2021-07-01 09:29:32 UTC\n \n 2021-07-14 09:21: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 1083\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:29:32',4,'2021-07-14 09:21:43',4,0,NULL,NULL,NULL,'34ff952a-26df-412d-a502-d6221f35c47e'),(1084,'Clients given 4f','All Clients given 4f, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4f\n All Clients given 4f, Seen and MMD\n \n 2021-07-01 09:30:43 UTC\n \n 2021-07-14 09:22: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 1084\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:30:43',4,'2021-07-14 09:22:26',4,0,NULL,NULL,NULL,'b33afbb9-4ac6-4be4-85e4-a282f8f10217'),(1085,'Clients given 4g','All Clients given 4g, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4g\n All Clients given 4g, Seen and MMD\n \n 2021-07-01 09:31:36 UTC\n \n 2021-07-14 09:24: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 1085\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:31:36',4,'2021-07-14 09:24:27',4,0,NULL,NULL,NULL,'a80b2968-8f65-41f3-881b-f7a0cc83b93a'),(1086,'Clients given 4h','All Clients given 4h, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4h\n All Clients given 4h, Seen and MMD\n \n 2021-07-01 09:32:40 UTC\n \n 2021-07-14 09:30: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 1086\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:32:40',4,'2021-07-14 09:30:42',4,0,NULL,NULL,NULL,'cb49fed7-1491-4877-8963-fdc9f865e0a6'),(1087,'Clients given 4j','All Clients given 4j, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4j\n All Clients given 4j, Seen and MMD\n \n 2021-07-01 09:33:37 UTC\n \n 2021-07-14 09:31: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 1087\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:33:37',4,'2021-07-14 09:31:19',4,0,NULL,NULL,NULL,'b17ab786-8ff7-41d6-8d1f-7e6ad1386455'),(1088,'Clients given 4k','All Clients given 4k, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4k\n All Clients given 4k, Seen and MMD\n \n 2021-07-01 09:34:51 UTC\n \n 2021-07-14 09:32: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 1088\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:34:51',4,'2021-07-14 09:32:01',4,0,NULL,NULL,NULL,'ca02b119-2d87-464d-971b-23560d54934f'),(1089,'Clients given 4L','All Clients given 4L, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L\n All Clients given 4L, Seen and MMD\n \n 2021-07-01 09:35:43 UTC\n \n 2021-07-14 09:34: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 1089\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:35:43',4,'2021-07-14 09:34:14',4,0,NULL,NULL,NULL,'15d2f499-f37c-454b-bdd0-cfdec1a9822e'),(1090,'Clients given 5a','All Clients given 5a, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5a\n All Clients given 5a, Seen and MMD\n \n 2021-07-01 09:36:31 UTC\n \n 2021-07-14 09:35: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 1090\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:36:31',4,'2021-07-14 09:35:49',4,0,NULL,NULL,NULL,'92ff32c5-1f97-40c8-a00e-f5510a1844fe'),(1091,'Clients given 5b','All Clients given 5b, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5b\n All Clients given 5b, Seen and MMD\n \n 2021-07-01 09:37:38 UTC\n \n 2021-07-14 09: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 1091\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:37:38',4,'2021-07-14 09:42:28',4,0,NULL,NULL,NULL,'b673009d-635d-4656-86f4-3e8b333c30c5'),(1092,'Clients given 5c','All Clients given 5c, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5c\n All Clients given 5c, Seen and MMD\n \n 2021-07-01 09:38:32 UTC\n \n 2021-07-14 09:41: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 1092\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:38:32',4,'2021-07-14 09:41:27',4,0,NULL,NULL,NULL,'bfd23091-3c9d-4d67-8499-b0aa368bfb0d'),(1093,'Clients given 5d','All Clients given 5d, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5d\n All Clients given 5d, Seen and MMD\n \n 2021-07-01 09:39:29 UTC\n \n 2021-07-14 09:43: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 1093\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:39:29',4,'2021-07-14 09:43:02',4,0,NULL,NULL,NULL,'8db1f900-d2a1-4ba5-b563-b7daf9022432'),(1094,'Clients given 5e','All Clients given 5e, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5e\n All Clients given 5e, Seen and MMD\n \n 2021-07-01 09:40:22 UTC\n \n 2021-07-14 09:43: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 1094\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:40:22',4,'2021-07-14 09:43:40',4,0,NULL,NULL,NULL,'c00787d2-2c6c-4597-994b-049aad75c1aa'),(1095,'Clients given 5f','All Clients given 5f, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5f\n All Clients given 5f, Seen and MMD\n \n 2021-07-01 09:41:11 UTC\n \n 2021-07-14 09:44: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 1095\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:41:11',4,'2021-07-14 09:44:37',4,0,NULL,NULL,NULL,'09a901cd-d076-4d07-b59e-23721346dab7'),(1096,'Clients given 5g','All Clients given 5g, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5g\n All Clients given 5g, Seen and MMD\n \n 2021-07-01 09:42:14 UTC\n \n 2021-07-14 09:45: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 1096\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:42:14',4,'2021-07-14 09:45:16',4,0,NULL,NULL,NULL,'8263e9c9-9136-42b4-8af1-e0c11cf5a2b5'),(1097,'Clients given 5h','All Clients given 5h, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5h\n All Clients given 5h, Seen and MMD\n \n 2021-07-01 09:45:28 UTC\n \n 2021-07-14 09:46: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 1097\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:45:28',4,'2021-07-14 09:46:20',4,0,NULL,NULL,NULL,'0639ed8d-f2ab-4389-9451-95c9cb8ee20c'),(1098,'Clients given 6a','All Clients given 6a, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6a\n All Clients given 6a, Seen and MMD\n \n 2021-07-01 09:46:22 UTC\n \n 2021-07-14 09:50: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 1098\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:46:22',4,'2021-07-14 09:50:16',4,0,NULL,NULL,NULL,'67fe820f-2c01-4b2a-94bb-93d1544cf719'),(1099,'Clients given 6b','All Clients given 6b, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6b\n All Clients given 6b, Seen and MMD\n \n 2021-07-01 09:47:17 UTC\n \n 2021-07-14 09:50: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 1099\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:47:17',4,'2021-07-14 09:50:37',4,0,NULL,NULL,NULL,'68e1057e-a950-4c30-85d5-51519020a3f7'),(1100,'Clients given 6c','All Clients given 6c, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6c\n All Clients given 6c, Seen and MMD\n \n 2021-07-01 09:48:03 UTC\n \n 2021-07-14 09:51: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 1100\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:48:03',4,'2021-07-14 09:51:11',4,0,NULL,NULL,NULL,'66d5fd18-9b6a-47d6-9c4b-9810d4dd8a6f'),(1101,'Clients given 6d','All Clients given 6d, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6d\n All Clients given 6d, Seen and MMD\n \n 2021-07-01 09:49:08 UTC\n \n 2021-07-14 09:51: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 1101\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:49:08',4,'2021-07-14 09:51:42',4,0,NULL,NULL,NULL,'36889bfc-5c40-43fb-8a08-211c12598e8e'),(1102,'Clients given 6e','All Clients given 6e, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6e\n All Clients given 6e, Seen and MMD\n \n 2021-07-01 09:49:58 UTC\n \n 2021-07-14 09:52: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 1102\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:49:58',4,'2021-07-14 09:52:32',4,0,NULL,NULL,NULL,'05c4c823-7f89-494e-9dc9-c8b64c41023f'),(1103,'Clients given 6f','All Clients given 6f, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6f\n All Clients given 6f, Seen and MMD\n \n 2021-07-01 09:50:50 UTC\n \n 2021-07-14 09:53: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 1103\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:50:50',4,'2021-07-14 09:53:28',4,0,NULL,NULL,NULL,'1e55140b-a007-456a-a680-a4f9f20a192f'),(1104,'2021_adult_arv_2ndline_regimen','Adult 2nd Line Regimen Report including \"other\" supply duration','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2021_adult_arv_2ndline_regimen\n Adult 2nd Line Regimen Report including "other" supply duration\n \n 2021-07-24 21:08:07 UTC\n \n 2021-07-24 21:08: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 1104\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','2021-07-24 21:08:07',4,'2021-07-24 21:08:14',4,0,NULL,NULL,NULL,'65dc07c7-72f2-48bb-af53-7e978056539c'),(1105,'2021_adult_arv_2ndline_regimen Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2021_adult_arv_2ndline_regimen Data Set\n \n 2021-07-24 21:08:14 UTC\n \n 2021-07-25 00:06: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 1105\n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 2c1month\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_Age\n 15+yrs\n \n \n \n \n \n 2c3months\n \n \n \n \n \n \n \n \n \n 2cOther\n \n \n \n \n \n \n \n \n \n 2d1month\n \n \n \n \n \n \n \n \n \n 2d3months\n \n \n \n \n \n \n \n \n \n 2dOther\n \n \n \n \n \n \n \n \n \n 2e1month\n \n \n \n \n \n \n \n \n \n 2e3months\n \n \n \n \n \n \n \n \n \n 2eOther\n \n \n \n \n \n \n \n \n \n 2f1month\n \n \n \n \n \n \n \n \n \n 2f3months\n \n \n \n \n \n \n \n \n \n 2fOther\n \n \n \n \n \n \n \n \n \n 2g1month\n \n \n \n \n \n \n \n \n \n 2g3months\n \n \n \n \n \n \n \n \n \n 2gOther\n \n \n \n \n \n \n \n \n \n 2h1month\n \n \n \n \n \n \n \n \n \n 2h3months\n \n \n \n \n \n \n \n \n \n 2hOther\n \n \n \n \n \n \n \n \n \n 2i1month\n \n \n \n \n \n \n \n \n \n 2i3months\n \n \n \n \n \n \n \n \n \n 2iOther\n \n \n \n \n \n \n \n \n \n 2j1month\n \n \n \n \n \n \n \n \n \n 2j3months\n \n \n \n \n \n \n \n \n \n 2jOther\n \n \n \n \n \n \n \n \n \n 2k1month\n \n \n \n \n \n \n \n \n \n 2k3months\n \n \n \n \n \n \n \n \n \n 2kOther\n \n \n \n \n \n \n \n \n \n 2l1month\n \n \n \n \n \n \n \n \n \n 2l3months\n \n \n \n \n \n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n 2lOther\n \n \n \n \n \n \n \n \n \n 2m1month\n \n \n \n \n \n \n \n \n \n 2m3months\n \n \n \n \n \n \n \n \n \n 2mOther\n \n \n \n \n \n \n \n \n \n 2n1month\n \n \n \n \n \n \n \n \n \n 2n3months\n \n \n \n \n \n \n \n \n \n 2nOther\n \n \n \n \n \n \n \n \n \n 2o1month\n \n \n \n \n \n \n \n \n \n 2o3months\n \n \n \n \n \n \n \n \n \n 2oOther\n \n \n \n \n \n \n \n \n \n 2p1month\n \n \n \n \n \n \n \n \n \n 2p3months\n \n \n \n \n \n \n \n \n \n 2pOther\n \n \n \n \n \n \n \n \n \n 2q1month\n \n \n \n \n \n \n \n \n \n 2q3months\n \n \n \n \n \n \n \n \n \n 2qOther\n \n \n \n \n \n \n \n \n \n 2r1month\n \n \n \n \n \n \n \n \n \n 2r3months\n \n \n \n \n \n \n \n \n \n 2rOther\n \n \n \n \n \n \n \n \n \n 2s1month\n \n \n \n \n \n \n \n \n \n 2s3months\n \n \n \n \n \n \n \n \n \n 2sOther\n \n \n \n \n \n \n \n \n \n','2021-07-24 21:08:14',4,'2021-07-25 00:06:41',4,0,NULL,NULL,NULL,'63481a60-98f4-448d-b87f-81c26b3428a2'),(1106,'Clients given Other months MMD supply 2i','Clients given Other months MMD supply 2i','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2i\n Clients given Other months MMD supply 2i\n \n 2021-07-24 22:12:47 UTC\n \n 2021-07-24 22: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 1106\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3678)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:12:47',4,'2021-07-24 22:13:34',4,0,NULL,NULL,NULL,'9a098a70-340d-4abf-8812-e8a7af58e41f'),(1107,'Clients given Other months MMD supply 3a','Clients given Other months MMD supply 3a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 3a\n Clients given Other months MMD supply 3a\n \n 2021-07-24 22:14:16 UTC\n \n 2021-07-25 15:39: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 1107\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3683)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:14:16',4,'2021-07-25 15:39:52',4,0,NULL,NULL,NULL,'1beb1f89-253e-4989-86d6-79519e6d1991'),(1108,'Clients given Other months MMD supply 3b','Clients given Other months MMD supply 3b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 3b\n Clients given Other months MMD supply 3b\n \n 2021-07-24 22:15:29 UTC\n \n 2021-07-25 17:23: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 1108\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3684)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:15:29',4,'2021-07-25 17:23:48',4,0,NULL,NULL,NULL,'0c074440-2184-41fd-a989-cd5eab20e861'),(1109,'Clients given Other months MMD supply 3c','Clients given Other months MMD supply 3c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 3c\n Clients given Other months MMD supply 3c\n \n 2021-07-24 22:17:06 UTC\n \n 2021-07-25 17:24:42 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n 1109\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3685)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:17:06',4,'2021-07-25 17:24:42',4,0,NULL,NULL,NULL,'8197eb7b-2d9c-4dae-b527-342d7a2fc049'),(1110,'Clients given Other months MMD supply 3d','Clients given Other months MMD supply 3d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 3d\n Clients given Other months MMD supply 3d\n \n 2021-07-24 22:17:16 UTC\n \n 2021-07-25 17:25: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 1110\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4706)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:17:16',4,'2021-07-25 17:25:45',4,0,NULL,NULL,NULL,'6e1a7efa-9a36-440e-8fce-17afb7d33a70'),(1111,'Clients given Other months MMD supply 3e','Clients given Other months MMD supply 3e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 3e\n Clients given Other months MMD supply 3e\n \n 2021-07-24 22:17:25 UTC\n \n 2021-07-25 17:26: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 1111\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4707)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:17:25',4,'2021-07-25 17:26:26',4,0,NULL,NULL,NULL,'7f6ea741-a3bf-4488-a354-9a258d65d49d'),(1112,'Clients given Other months MMD supply 3f','Clients given Other months MMD supply 3f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 3f\n Clients given Other months MMD supply 3f\n \n 2021-07-24 22:17:38 UTC\n \n 2021-07-25 15:41: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 1112\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4708)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:17:38',4,'2021-07-25 15:41:48',4,0,NULL,NULL,NULL,'2e6f05f5-2959-48b1-95e6-82ce7fbe83c2'),(1113,'Clients given Other months MMD supply 3g','Clients given Other months MMD supply 3g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 3g\n Clients given Other months MMD supply 3g\n \n 2021-07-24 22:17:47 UTC\n \n 2021-07-25 17: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 1113\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4709)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:17:47',4,'2021-07-25 17:27:36',4,0,NULL,NULL,NULL,'6374a1da-a30b-4a63-8199-c4c44b3b8221'),(1114,'Clients given Other months MMD supply 3h','Clients given Other months MMD supply 3h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 3h\n Clients given Other months MMD supply 3h\n \n 2021-07-24 22:17:57 UTC\n \n 2021-07-25 17:28: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 1114\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4710)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:17:57',4,'2021-07-25 17:28:30',4,0,NULL,NULL,NULL,'e46ed914-5afc-4fe5-ac10-9380c044140d'),(1115,'adult_arv_2c_other','2c other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2c_other\n 2c other months\n \n 2021-07-24 22:39:05 UTC\n \n 2021-07-24 22: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 1115\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:39:05',4,'2021-07-24 22:42:43',4,0,NULL,NULL,NULL,'bb9efe71-8a37-4920-8337-8b62d6bd950f'),(1116,'adult_arv_2d_other','2d other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2d_other\n 2d other months\n \n 2021-07-24 22:44:29 UTC\n \n 2021-07-24 22:45: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 1116\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:44:29',4,'2021-07-24 22:45:24',4,0,NULL,NULL,NULL,'995e2f09-0737-451b-bdc6-e2c3c984506d'),(1117,'adult_arv_2e_other','2e other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2e_other\n 2e other months\n \n 2021-07-24 22:46:28 UTC\n \n 2021-07-24 22:47: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 1117\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:46:28',4,'2021-07-24 22:47:20',4,0,NULL,NULL,NULL,'e8a532b2-29ed-4684-b720-9a676e27d3e3'),(1118,'adult_arv_2f_other','2f other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2f_other\n 2f other months\n \n 2021-07-24 22:48:05 UTC\n \n 2021-07-24 22:49: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 1118\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:48:05',4,'2021-07-24 22:49:00',4,0,NULL,NULL,NULL,'49044e15-08f6-49d8-8286-b490a18b84cc'),(1119,'adult_arv_2g_other','2g other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2g_other\n 2g other months\n \n 2021-07-24 22:49:33 UTC\n \n 2021-07-24 22:50: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 1119\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:49:33',4,'2021-07-24 22:50:25',4,0,NULL,NULL,NULL,'1fa9b60f-c81a-4db8-8c5c-37f4171488ab'),(1120,'adult_arv_2h_other','2h other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2h_other\n 2h other months\n \n 2021-07-24 22:50:50 UTC\n \n 2021-07-24 22:51: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 1120\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:50:50',4,'2021-07-24 22:51:47',4,0,NULL,NULL,NULL,'31df4ed6-1c06-4b03-b057-18f98d16e86d'),(1121,'adult_arv_2i_other','2i other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2i_other\n 2i other months\n \n 2021-07-24 22:52:21 UTC\n \n 2021-07-24 22: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 1121\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:52:21',4,'2021-07-24 22:53:20',4,0,NULL,NULL,NULL,'3115d4f6-4fdf-4376-9e35-fa9a056fd8ba'),(1122,'adult_arv_2j_other','2j other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2j_other\n 2j other months\n \n 2021-07-24 22:55:26 UTC\n \n 2021-07-24 22:56: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 1122\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:55:26',4,'2021-07-24 22:56:15',4,0,NULL,NULL,NULL,'3c32b136-f8bc-4f36-9df9-462b98caa9df'),(1123,'adult_arv_2k_other','2k other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2k_other\n 2k other months\n \n 2021-07-24 22:56:42 UTC\n \n 2021-07-24 22:57: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 1123\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:56:42',4,'2021-07-24 22:57:38',4,0,NULL,NULL,NULL,'eeaf0be9-720b-4017-85c8-8c4c66751aa0'),(1124,'adult_arv_2L_other','2L other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2L_other\n 2L other months\n \n 2021-07-24 22:58:13 UTC\n \n 2021-07-24 22: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 1124\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:58:13',4,'2021-07-24 22:59:11',4,0,NULL,NULL,NULL,'6b8264e4-47f3-4097-9f2f-9c753da5d2eb'),(1125,'adult_arv_2m_other','2m other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2m_other\n 2m other months\n \n 2021-07-24 22:59:40 UTC\n \n 2021-07-24 23: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 1125\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:59:40',4,'2021-07-24 23:00:31',4,0,NULL,NULL,NULL,'328d6fe0-827b-43ed-9547-2b8a171b8d37'),(1126,'adult_arv_2n_other','2n other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2n_other\n 2n other months\n \n 2021-07-24 23:01:01 UTC\n \n 2021-07-24 23:01: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 1126\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 23:01:01',4,'2021-07-24 23:01:49',4,0,NULL,NULL,NULL,'eb60c530-b24b-4abb-b0ea-c24552bfe2bc'),(1127,'adult_arv_2o_other','2o other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2o_other\n 2o other months\n \n 2021-07-24 23:02:19 UTC\n \n 2021-07-24 23: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 1127\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 23:02:19',4,'2021-07-24 23:03:14',4,0,NULL,NULL,NULL,'cb68b1db-7af4-458b-b7da-976df2a7ff5c'),(1128,'adult_arv_2p_other','2p other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2p_other\n 2p other months\n \n 2021-07-24 23:03:49 UTC\n \n 2021-07-24 23: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 1128\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 23:03:49',4,'2021-07-24 23:04:47',4,0,NULL,NULL,NULL,'b5ebac06-f1eb-4b1d-b845-1b3189d41a19'),(1129,'adult_arv_2q_other','2q other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2q_other\n 2q other months\n \n 2021-07-24 23:05:21 UTC\n \n 2021-07-24 23:06: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 1129\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 23:05:21',4,'2021-07-24 23:06:14',4,0,NULL,NULL,NULL,'6a8d6891-b916-407b-8b79-81dc51764f86'),(1130,'adult_arv_2r_other','2r other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2r_other\n 2r other months\n \n 2021-07-24 23:06:40 UTC\n \n 2021-07-24 23:09: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 1130\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 23:06:40',4,'2021-07-24 23:09:31',4,0,NULL,NULL,NULL,'7fbbc619-a1f7-4826-b0f1-e97ddbbc0b71'),(1131,'adult_arv_2s_other','2s other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2s_other\n 2s other months\n \n 2021-07-24 23:10:01 UTC\n \n 2021-07-24 23:12: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 1131\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 23:10:01',4,'2021-07-24 23:12:22',4,0,NULL,NULL,NULL,'eb4df91c-f55d-40ab-bd9c-de172dc40fb3'),(1132,' CI20b: Adult 3rd Line other months supply 3a','3a other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI20b: Adult 3rd Line other months supply 3a\n 3a other months\n \n 2021-07-25 17:30:04 UTC\n \n 2021-07-25 17:37: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 1132\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-25 17:30:04',4,'2021-07-25 17:37:28',4,0,NULL,NULL,NULL,'08c4ce55-b96a-4f36-8102-3d1ce8f756df'),(1133,' CI21b: Adult 3rd Line other months supply 3b','3b other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI21b: Adult 3rd Line other months supply 3b\n 3b other months\n \n 2021-07-25 17:38:59 UTC\n \n 2021-07-25 17:40: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 1133\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-25 17:38:59',4,'2021-07-25 17:40:05',4,0,NULL,NULL,NULL,'93f9b74b-83a0-4f9b-a8a6-f2c849d7cad9'),(1134,'CI22b: Adult 3rd Line other months supply 3c','3c other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI22b: Adult 3rd Line other months supply 3c\n 3c other months\n \n 2021-07-25 17:41:04 UTC\n \n 2021-07-25 17:42: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 1134\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-25 17:41:04',4,'2021-07-25 17:42:04',4,0,NULL,NULL,NULL,'8953f6bf-99ef-4f9b-b62e-71aa6658d8d6'),(1135,' CI40b: Adult 3rd Line other months supply 3d','3d other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI40b: Adult 3rd Line other months supply 3d\n 3d other months\n \n 2021-07-25 17:54:44 UTC\n \n 2021-07-25 17: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 1135\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-25 17:54:44',4,'2021-07-25 17:55:29',4,0,NULL,NULL,NULL,'0e2ae3a1-7e4a-4daf-b45e-0d56d09857f5'),(1136,'CI41b: Adult 3rd Line other months supply 3e','3e other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI41b: Adult 3rd Line other months supply 3e\n 3e other months\n \n 2021-07-25 17:56:28 UTC\n \n 2021-07-25 17:57: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 1136\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-25 17:56:28',4,'2021-07-25 17:57:31',4,0,NULL,NULL,NULL,'05be785f-976a-4fd6-939a-848136cddff7'),(1137,' CI42b: Adult 3rd Line other months supply 3f','3f other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI42b: Adult 3rd Line other months supply 3f\n 3f other months\n \n 2021-07-25 17:58:16 UTC\n \n 2021-07-25 17:59: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 1137\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-25 17:58:16',4,'2021-07-25 17:59:08',4,0,NULL,NULL,NULL,'211858e4-23d9-4138-9e74-5204b3a621fa'),(1138,'CI43b: Adult 3rd Line other months supply 3g','3g other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI43b: Adult 3rd Line other months supply 3g\n 3g other months\n \n 2021-07-25 17:59:56 UTC\n \n 2021-07-25 18: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 1138\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-25 17:59:56',4,'2021-07-25 18:00:42',4,0,NULL,NULL,NULL,'0aafe8ee-3a67-4d76-a457-c5ca4d7858bf'),(1139,'CI44b: Adult 3rd Line other months supply 3h','3h other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI44b: Adult 3rd Line other months supply 3h\n 3h other months\n \n 2021-07-25 18:01:42 UTC\n \n 2021-07-25 18:02: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 1139\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-25 18:01:42',4,'2021-07-25 18:02:38',4,0,NULL,NULL,NULL,'3abd957f-7936-4ee4-83e7-315a78da3dd4'),(1140,'2021_adult_arv_3rdline_regimen','Adult 3rd Line Regimen Report including \"other\" supply duration','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2021_adult_arv_3rdline_regimen\n Adult 3rd Line Regimen Report including "other" supply duration\n \n 2021-07-25 18:05:12 UTC\n \n 2021-07-25 18:05: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 1140\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','2021-07-25 18:05:12',4,'2021-07-25 18:05:19',4,0,NULL,NULL,NULL,'d91aae02-390f-4f91-9b6f-ff17d9b03fc5'),(1141,'2021_adult_arv_3rdline_regimen Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2021_adult_arv_3rdline_regimen Data Set\n \n 2021-07-25 18:05:19 UTC\n \n 2021-07-25 18:15: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 1141\n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 3a_Other\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_Age\n 15+yrs\n \n \n \n \n \n 3a1mnth\n \n \n \n \n \n \n \n \n \n 3b_Other\n \n \n \n \n \n \n \n \n \n 3b1month\n \n \n \n \n \n \n \n \n \n 3c_Other\n \n \n \n \n \n \n \n \n \n 3c1month\n \n \n \n \n \n \n \n \n \n 3d_Other\n \n \n \n \n \n \n \n \n \n 3d1month\n \n \n \n \n \n \n \n \n \n 3e_Other\n \n \n \n \n \n \n \n \n \n 3e1month\n \n \n \n \n \n \n \n \n \n 3f_Other\n \n \n \n \n \n \n \n \n \n 3f1month\n \n \n \n \n \n \n \n \n \n 3g_Other\n \n \n \n \n \n \n \n \n \n 3g1month\n \n \n \n \n \n \n \n \n \n 3h_Other\n \n \n \n \n \n \n \n \n \n 3h1month\n \n \n \n \n \n \n \n \n \n','2021-07-25 18:05:19',4,'2021-07-25 18:15:08',4,0,NULL,NULL,NULL,'67697a30-c7a6-4e60-bb91-cd5e5a4f779e'),(1142,'VL-01 Routine VL tests performed','Total number of VL test results received','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-01 Routine VL tests performed\n Total number of VL test results received\n \n 2021-08-05 12:20:57 UTC\n \n 2021-08-05 12: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 1142\n SELECT person_id \nFROM \n( \n select distinct o.person_id, \n IF(latest_vl_result = 4264, 'LessThan20', IF(latest_vl_result = 4263, 'Undetectable', latest_numeric_vl_result)) AS VL_Result, \n IF(latest_indication_vl = 4281, 'Routine', 'Targeted') as Indication \n \n from obs o INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 4266 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_latest on o.person_id = obs_vl_latest.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n LEFT JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_numeric)), 20) AS latest_numeric_vl_result \n from obs oss \n where oss.concept_id = 2254 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_numeric_latest on o.person_id = obs_vl_numeric_latest.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed \nwhere Indication = 'Routine'\n','2021-08-05 17:50:57',4,'2021-08-05 17:51:13',4,0,NULL,NULL,NULL,'76c4f7ee-6714-44d0-a8e6-33410c683785'),(1143,'VL-02 Routine suppressed VL test results','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-02 Routine suppressed VL test results\n \n \n 2021-08-05 12:22:16 UTC\n \n 2024-02-05 19: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 1143\n SELECT person_id \nFROM \n( \n select distinct o.person_id \n \n from obs o \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- lessThan20 \n where oss.concept_id = 4266 and oss.value_coded = 4264 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LessThan20 \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- lUndetectable \n where oss.concept_id = 4266 and oss.value_coded = 4263 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LessThan20 \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- less than 1000 copies \n where oss.concept_id = 4266 and oss.value_coded = 4265 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.person_id in \n ( \n select person_id \n from obs o \n where o.concept_id = 2254 \n and o.value_numeric < 1000 \n ) \n group by oss.person_id \n \n ) As LessThan1000copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5485 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.value_numeric < 1000 \n group by oss.person_id \n \n ) As Lab_Copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5489 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LDL \n \n order by Id \n \n ) as obs_vl_latest \n on obs_vl_latest.Id = o.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.value_coded = 4281 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 17:52:16',4,'2024-02-06 01:15:51',4,0,NULL,NULL,NULL,'b38f5df3-b850-40c3-9de4-28ac12061621'),(1144,'VL-03 Routine detectable VL test results','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-03 Routine detectable VL test results\n \n \n 2021-08-05 12:23:24 UTC\n \n 2024-02-05 19:49: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 1144\n SELECT person_id \nFROM \n( \n select distinct o.person_id \n \n from obs o \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- More than 1000 copies \n where oss.concept_id = 4266 and oss.value_coded = 4265 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.person_id in \n ( \n select person_id \n from obs o \n where o.concept_id = 2254 \n and o.value_numeric > 1000 \n ) \n group by oss.person_id \n \n ) As MoreThan1000copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5485 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.value_numeric > 1000 \n group by oss.person_id \n \n ) As Lab_Copies \n \n order by Id \n \n ) as obs_vl_latest \n on obs_vl_latest.Id = o.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.value_coded = 4281 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 17:53:24',4,'2024-02-06 01:19:06',4,0,NULL,NULL,NULL,'6597528a-3622-4020-a187-80f96ded9817'),(1145,'VL-04 Targeted VL tests performed','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-04 Targeted VL tests performed\n \n \n 2021-08-05 12:24:38 UTC\n \n 2021-08-05 12:24: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 1145\n SELECT person_id \nFROM \n( \n select distinct o.person_id, \n IF(latest_vl_result = 4264, 'LessThan20', IF(latest_vl_result = 4263, 'Undetectable', latest_numeric_vl_result)) AS VL_Result, \n IF(latest_indication_vl = 4281, 'Routine', 'Targeted') as Indication \n \n from obs o INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 4266 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_latest on o.person_id = obs_vl_latest.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n LEFT JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_numeric)), 20) AS latest_numeric_vl_result \n from obs oss \n where oss.concept_id = 2254 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_numeric_latest on o.person_id = obs_vl_numeric_latest.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed \nwhere Indication = 'Targeted'\n','2021-08-05 17:54:38',4,'2021-08-05 17:54:54',4,0,NULL,NULL,NULL,'7a0d9c5b-e86d-4c06-8e83-487fc8f9238c'),(1146,'VL-05 Targeted suppressed VL test results','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-05 Targeted suppressed VL test results\n \n \n 2021-08-05 12:25:43 UTC\n \n 2024-02-05 19:47: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 1146\n SELECT person_id \nFROM \n( \n select distinct o.person_id \n \n from obs o \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- lessThan20 \n where oss.concept_id = 4266 and oss.value_coded = 4264 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LessThan20 \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- lUndetectable \n where oss.concept_id = 4266 and oss.value_coded = 4263 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LessThan20 \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- less than 1000 copies \n where oss.concept_id = 4266 and oss.value_coded = 4265 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.person_id in \n ( \n select person_id \n from obs o \n where o.concept_id = 2254 \n and o.value_numeric < 1000 \n ) \n group by oss.person_id \n \n ) As LessThan1000copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5485 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.value_numeric < 1000 \n group by oss.person_id \n \n ) As Lab_Copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5489 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LDL \n \n order by Id \n \n ) as obs_vl_latest \n on obs_vl_latest.Id = o.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.value_coded = 4282 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 17:55:43',4,'2024-02-06 01:17:08',4,0,NULL,NULL,NULL,'ca8302ef-0acb-4fa6-9767-2e228b2423c3'),(1147,'VL-06 Targeted detectable VL test results','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-06 Targeted detectable VL test results\n \n \n 2021-08-05 12:26:58 UTC\n \n 2024-02-05 19:50: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 1147\n SELECT person_id \nFROM \n( \n select distinct o.person_id \n \n from obs o \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- More than 1000 copies \n where oss.concept_id = 4266 and oss.value_coded = 4265 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.person_id in \n ( \n select person_id \n from obs o \n where o.concept_id = 2254 \n and o.value_numeric > 1000 \n ) \n group by oss.person_id \n \n ) As MoreThan1000copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5485 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.value_numeric > 1000 \n group by oss.person_id \n \n ) As Lab_Copies \n \n order by Id \n \n ) as obs_vl_latest \n on obs_vl_latest.Id = o.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.value_coded = 4282 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 17:56:58',4,'2024-02-06 01:20:01',4,0,NULL,NULL,NULL,'13d934cf-bdf0-4ac9-a4e4-fe9deda7168e'),(1148,'VL-10 Pregnant Women VL tests performed','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-10 Pregnant Women VL tests performed\n \n \n 2021-08-05 12:28:31 UTC\n \n 2024-02-05 19:07: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 1148\n SELECT person_id \nFROM \n( \n select distinct o.person_id, \n IF(latest_indication_vl = 4281, 'Routine', 'Targeted') as Indication \n \n from obs o INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_draw \n from obs oss \n where oss.concept_id = 4276 and oss.value_coded = 4277 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_latest on o.person_id = obs_vl_latest.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.encounter_id )), 20) AS latest_pregnancy_status \n from obs oss \n where oss.concept_id = 4278 and oss.value_coded = 2146 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) as obs_latest_pregnant_status on o.person_id = obs_latest_pregnant_status.person_id \n \n) as all_vl_tests_performed\n','2021-08-05 17:58:31',4,'2024-02-06 00:37:50',4,0,NULL,NULL,NULL,'9bc3c3e8-f637-4eac-b2e3-1b185917d8bf'),(1149,'VL-11 Pregnant women suppressed VL test results','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-11 Pregnant women suppressed VL test results\n \n \n 2021-08-05 12:29:56 UTC\n \n 2024-02-05 19:33: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 1149\n SELECT person_id \nFROM \n( \n select distinct o.person_id \n \n from obs o \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- lessThan20 \n where oss.concept_id = 4266 and oss.value_coded = 4264 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LessThan20 \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- lUndetectable \n where oss.concept_id = 4266 and oss.value_coded = 4263 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LessThan20 \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- less than 1000 copies \n where oss.concept_id = 4266 and oss.value_coded = 4265 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.person_id in \n ( \n select person_id \n from obs o \n where o.concept_id = 2254 \n and o.value_numeric < 1000 \n ) \n group by oss.person_id \n \n ) As LessThan1000copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5485 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.value_numeric < 1000 \n group by oss.person_id \n \n ) As Lab_Copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5489 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LDL \n \n order by Id \n \n ) as obs_vl_latest \n on obs_vl_latest.Id = o.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.encounter_id )), 20) AS latest_pregnancy_status \n from obs oss \n where oss.concept_id = 4278 and oss.value_coded = 2146 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) as obs_latest_breast_feeding_status on o.person_id = obs_latest_breast_feeding_status.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 17:59:56',4,'2024-02-06 01:03:46',4,0,NULL,NULL,NULL,'860d6c29-dccc-4e19-912f-60271aba1034'),(1150,'VL-12 Pregnant women detectable VL test results','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-12 Pregnant women detectable VL test results\n \n \n 2021-08-05 12:31:45 UTC\n \n 2024-02-05 19:37: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 1150\n SELECT person_id \nFROM \n( \n select distinct o.person_id \n \n from obs o \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- More than 1000 copies \n where oss.concept_id = 4266 and oss.value_coded = 4265 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.person_id in \n ( \n select person_id \n from obs o \n where o.concept_id = 2254 \n and o.value_numeric > 1000 \n ) \n group by oss.person_id \n \n ) As MoreThan1000copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5485 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.value_numeric > 1000 \n group by oss.person_id \n \n ) As Lab_Copies \n \n order by Id \n \n ) as obs_vl_latest \n on obs_vl_latest.Id = o.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.encounter_id )), 20) AS latest_pregnancy_status \n from obs oss \n where oss.concept_id = 4278 and oss.value_coded = 2146 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) as obs_latest_breast_feeding_status on o.person_id = obs_latest_breast_feeding_status.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 18:01:45',4,'2024-02-06 01:07:45',4,0,NULL,NULL,NULL,'f08fe06d-88e4-404b-baba-065c9f71a48e'),(1151,'VL-13 Breastfeeding mothers VL tests performed','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-13 Breastfeeding mothers VL tests performed\n \n \n 2021-08-05 12:32:45 UTC\n \n 2024-02-05 18:33: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 1151\n SELECT person_id \nFROM \n( \n select distinct o.person_id, \n IF(latest_indication_vl = 4281, 'Routine', 'Targeted') as Indication \n \n from obs o INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_draw \n from obs oss \n where oss.concept_id = 4276 and oss.value_coded = 4277 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_latest on o.person_id = obs_vl_latest.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.encounter_id )), 20) AS latest_pregnancy_status \n from obs oss \n where oss.concept_id = 4279 and oss.value_coded = 2146 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) as obs_latest_breast_feeding_status on o.person_id = obs_latest_breast_feeding_status.person_id \n \n) as all_vl_tests_performed\n','2021-08-05 18:02:45',4,'2024-02-06 00:03:06',4,0,NULL,NULL,NULL,'86b11e45-84ca-453b-98db-20eec3fd63f0'),(1152,'VL-14 Breastfeeding mothers suppressed VL test','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-14 Breastfeeding mothers suppressed VL test\n \n \n 2021-08-05 12:33:53 UTC\n \n 2024-02-05 11:52: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 1152\n SELECT person_id \nFROM \n( \n select distinct o.person_id \n \n from obs o \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- lessThan20 \n where oss.concept_id = 4266 and oss.value_coded = 4264 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LessThan20 \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- lUndetectable \n where oss.concept_id = 4266 and oss.value_coded = 4263 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LessThan20 \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- less than 1000 copies \n where oss.concept_id = 4266 and oss.value_coded = 4265 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.person_id in \n ( \n select person_id \n from obs o \n where o.concept_id = 2254 \n and o.value_numeric < 1000 \n ) \n group by oss.person_id \n \n ) As LessThan1000copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5485 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.value_numeric < 1000 \n group by oss.person_id \n \n ) As Lab_Copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5489 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LDL \n \n order by Id \n \n ) as obs_vl_latest \n on obs_vl_latest.Id = o.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.encounter_id )), 20) AS latest_pregnancy_status \n from obs oss \n where oss.concept_id = 4279 and oss.value_coded = 2146 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) as obs_latest_breast_feeding_status on o.person_id = obs_latest_breast_feeding_status.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 18:03:53',4,'2024-02-05 17:22:54',4,0,NULL,NULL,NULL,'6b3c185a-0f25-4540-a61b-aaa9310f3fc5'),(1153,'VL-15 Breastfeeding mothers detectable VL test','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-15 Breastfeeding mothers detectable VL test\n \n \n 2021-08-05 12:35:21 UTC\n \n 2024-02-05 18:46: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 1153\n SELECT person_id \nFROM \n( \n select distinct o.person_id \n \n from obs o \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- More than 1000 copies \n where oss.concept_id = 4266 and oss.value_coded = 4265 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.person_id in \n ( \n select person_id \n from obs o \n where o.concept_id = 2254 \n and o.value_numeric > 1000 \n ) \n group by oss.person_id \n \n ) As MoreThan1000copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5485 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.value_numeric > 1000 \n group by oss.person_id \n \n ) As Lab_Copies \n \n order by Id \n \n ) as obs_vl_latest \n on obs_vl_latest.Id = o.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.encounter_id )), 20) AS latest_pregnancy_status \n from obs oss \n where oss.concept_id = 4279 and oss.value_coded = 2146 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) as obs_latest_breast_feeding_status on o.person_id = obs_latest_breast_feeding_status.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 18:05:21',4,'2024-02-06 00:16:38',4,0,NULL,NULL,NULL,'555e193a-3906-4920-98a4-f0b9c90d46df'),(1154,'VL-19 Clients with VL results received during reporting period','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-19 Clients with VL results received during reporting period\n \n \n 2021-08-05 12:36:45 UTC\n \n 2024-02-06 09:08: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 1154\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nwhere o.concept_id = 5494 \n and date(o.value_datetime) between cast(:startDate as date) and cast(:endDate as date) \n and (o.location_id = :location or parent_location = :location) \n and o.voided = 0\n','2021-08-05 18:06:45',4,'2024-02-06 14:38:08',4,0,NULL,NULL,NULL,'52f9140f-67e6-46d2-bf3b-d7a2b1654d94'),(1155,'VL-22 VL tests performed','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-22 VL tests performed\n \n \n 2021-08-05 12:38:45 UTC\n \n 2021-08-05 12:39: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 1155\n SELECT person_id \nFROM \n( \n select distinct o.person_id, \n IF(latest_vl_result = 4264, 'LessThan20', IF(latest_vl_result = 4263, 'Undetectable', latest_numeric_vl_result)) AS VL_Result, \n IF(latest_indication_vl = 4281, 'Routine', 'Targeted') as Indication \n \n from obs o INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 4266 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_latest on o.person_id = obs_vl_latest.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n LEFT JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_numeric)), 20) AS latest_numeric_vl_result \n from obs oss \n where oss.concept_id = 2254 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_numeric_latest on o.person_id = obs_vl_numeric_latest.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 18:08:45',4,'2021-08-05 18:09:05',4,0,NULL,NULL,NULL,'c228ed83-7fb8-4b0b-9345-3c9ec1e2ef70'),(1156,'VL-23 Suppressed VL test results','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-23 Suppressed VL test results\n \n \n 2021-08-05 12:41:47 UTC\n \n 2021-08-05 12:42: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 1156\n SELECT person_id \nFROM \n( \n select distinct o.person_id, \n IF(latest_vl_result = 4264, 'LessThan20', IF(latest_vl_result = 4263, 'Undetectable', latest_numeric_vl_result)) AS VL_Result, \n IF(latest_indication_vl = 4281, 'Routine', 'Targeted') as Indication \n \n from obs o INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 4266 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_latest on o.person_id = obs_vl_latest.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n LEFT JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_numeric)), 20) AS latest_numeric_vl_result \n from obs oss \n where oss.concept_id = 2254 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND CAST(:endDate AS DATE) \n group by oss.person_id \n having latest_numeric_vl_result < 1000 \n ) as obs_vl_numeric_latest on o.person_id = obs_vl_numeric_latest.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed \nwhere VL_Result is not null\n','2021-08-05 18:11:47',4,'2021-08-05 18:12:02',4,0,NULL,NULL,NULL,'11240ecc-df99-4519-81df-5bf965d2a5e3'); -INSERT INTO `serialized_object` VALUES (1157,'VL-24 Detectable VL test results','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-24 Detectable VL test results\n \n \n 2021-08-05 12:43:11 UTC\n \n 2021-08-05 12: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 1157\n SELECT person_id \nFROM \n( \n select distinct o.person_id, \n IF(latest_vl_result = 4264, 'LessThan20', IF(latest_vl_result = 4263, 'Undetectable', latest_numeric_vl_result)) AS VL_Result, \n IF(latest_indication_vl = 4281, 'Routine', 'Targeted') as Indication \n \n from obs o INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 4266 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_latest on o.person_id = obs_vl_latest.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n LEFT JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_numeric)), 20) AS latest_numeric_vl_result \n from obs oss \n where oss.concept_id = 2254 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_numeric_latest on o.person_id = obs_vl_numeric_latest.person_id \n INNER JOIN person ON person.person_id = o.person_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) as all_vl_tests_performed \nwhere person_id not in ( \n SELECT person_id \n FROM \n ( \n select distinct o.person_id, \n IF(latest_vl_result = 4264, 'LessThan20', IF(latest_vl_result = 4263, 'Undetectable', latest_numeric_vl_result)) AS VL_Result, \n IF(latest_indication_vl = 4281, 'Routine', 'Targeted') as Indication \n \n from obs o INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 4266 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_latest on o.person_id = obs_vl_latest.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n LEFT JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_numeric)), 20) AS latest_numeric_vl_result \n from obs oss \n where oss.concept_id = 2254 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND CAST(:endDate AS DATE) \n group by oss.person_id \n having latest_numeric_vl_result < 1000 \n ) as obs_vl_numeric_latest on o.person_id = obs_vl_numeric_latest.person_id \n INNER JOIN person ON person.person_id = o.person_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 ) as all_vl_tests_performed \n where VL_Result is not null \n)\n','2021-08-05 18:13:11',4,'2021-08-05 18:13:23',4,0,NULL,NULL,NULL,'008332f3-3206-459e-8bd9-dc2d228427f1'),(1158,'DM_VL_Age','','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n DM_VL_Age\n \n \n 2021-08-05 12:45:06 UTC\n \n 2021-08-05 13:50:13 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n 1158\n \n \n 1-4yrs\n \n \n \n \n maxAge\n 4\n \n \n minAge\n 1\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 15-19yrs\n \n \n \n \n maxAge\n 19\n \n \n minAge\n 15\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 20+\n \n \n \n \n minAge\n 20\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 20-150yrs\n \n \n \n \n maxAge\n 500\n \n \n minAge\n 20\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 5-14yrs\n \n \n \n \n maxAge\n 14\n \n \n minAge\n 5\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n Under 1yr\n \n \n \n \n maxAge\n 1\n \n \n minAge\n 0\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n','2021-08-05 18:15:06',4,'2021-08-05 19:20:13',4,0,NULL,NULL,NULL,'616ff52e-825e-478c-bfd0-280eae62a820'),(1159,'VL_IND-01 Routine VL tests performed','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-01 Routine VL tests performed\n \n \n 2021-08-05 12:50:14 UTC\n \n 2021-08-05 12:51: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 1159\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:20:14',4,'2021-08-05 18:21:12',4,0,NULL,NULL,NULL,'6c42812b-686f-4257-b46b-f24ac4faabfb'),(1160,'VL_IND-06 Targeted detectable VL test results','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-06 Targeted detectable VL test results\n \n \n 2021-08-05 12:51:41 UTC\n \n 2021-08-05 12:52: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 1160\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:21:41',4,'2021-08-05 18:22:10',4,0,NULL,NULL,NULL,'5fb9fa07-e08c-4928-b55e-01ba76096285'),(1161,'VL_IND-08 Pregnant women suppressed VL test results','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-08 Pregnant women suppressed VL test results\n \n \n 2021-08-05 12:52:43 UTC\n \n 2021-08-05 12: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 1161\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:22:43',4,'2021-08-05 18:23:20',4,0,NULL,NULL,NULL,'984eb638-7485-435a-b591-ff3c52051a95'),(1162,'VL_IND-02 Routine suppressed VL tests results','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-02 Routine suppressed VL tests results\n \n \n 2021-08-05 12:53:55 UTC\n \n 2021-08-05 12:54: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 1162\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:23:55',4,'2021-08-05 18:24:50',4,0,NULL,NULL,NULL,'b83be39f-5581-4112-81bd-d98643fa78a4'),(1163,'VL_IND-03 Routine detectable VL tests results','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-03 Routine detectable VL tests results\n \n \n 2021-08-05 12:55:25 UTC\n \n 2021-08-05 12:55: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 1163\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:25:25',4,'2021-08-05 18:25:54',4,0,NULL,NULL,NULL,'a907ba21-f8fe-451e-88bb-5c8a81dbbbc2'),(1164,'VL_IND-04 Targeted VL tests performed','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-04 Targeted VL tests performed\n \n \n 2021-08-05 12:56:41 UTC\n \n 2021-08-05 12:57: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 1164\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:26:41',4,'2021-08-05 18:27:28',4,0,NULL,NULL,NULL,'11ec8256-2f5f-43d9-9438-85d2c0a903de'),(1165,'VL_IND-05 Targeted suppressed VL test results','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-05 Targeted suppressed VL test results\n \n \n 2021-08-05 12:57:57 UTC\n \n 2021-08-09 20: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 1165\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 14:57:57',4,'2021-08-09 22:12:04',4,0,NULL,NULL,NULL,'0addd806-7fef-4d21-82b2-0428e4de1054'),(1166,'VL_IND-07 Pregnant women VL tests performed','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-07 Pregnant women VL tests performed\n \n \n 2021-08-05 12:59:41 UTC\n \n 2021-08-05 13:00: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 1166\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:29:41',4,'2021-08-05 18:30:46',4,0,NULL,NULL,NULL,'922201da-457f-4cd8-b11d-d6ad3d7728a7'),(1167,'VL_IND-09 Pregnant women detectable VL test results','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-09 Pregnant women detectable VL test results\n \n \n 2021-08-05 13:01:24 UTC\n \n 2021-08-05 13:02: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 1167\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:31:24',4,'2021-08-05 18:32:07',4,0,NULL,NULL,NULL,'eaef3f23-91fa-4a4e-bc9f-772d87f36358'),(1168,'VL_IND-10 Breastfeeding mothers VL tests performed','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-10 Breastfeeding mothers VL tests performed\n \n \n 2021-08-05 13:03:18 UTC\n \n 2021-08-05 13:03: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 1168\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:33:18',4,'2021-08-05 18:33:58',4,0,NULL,NULL,NULL,'01a09db0-e7a1-45ea-921b-9ade71ebf924'),(1169,'VL_IND-11 Breastfeeding mothers suppressed VL test results','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-11 Breastfeeding mothers suppressed VL test results\n \n \n 2021-08-05 13:04:56 UTC\n \n 2021-08-05 13:05: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 1169\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:34:56',4,'2021-08-05 18:35:35',4,0,NULL,NULL,NULL,'27ce60dd-678a-41b3-9990-c5844c0d340f'),(1170,'VL_IND-12 Breastfeeding mothers detectable VL test results','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-12 Breastfeeding mothers detectable VL test results\n \n \n 2021-08-05 13:06:10 UTC\n \n 2021-08-05 13:07: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 1170\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:36:10',4,'2021-08-05 18:37:06',4,0,NULL,NULL,NULL,'73d8d389-35a9-413f-baca-72120f9640cb'),(1171,'VL_IND-18 Clients with VL results received in reporting period','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-18 Clients with VL results received in reporting period\n \n \n 2021-08-05 13:07:56 UTC\n \n 2021-08-05 13:08: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 1171\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:37:56',4,'2021-08-05 18:38:36',4,0,NULL,NULL,NULL,'9855b2ec-294e-40be-8b8b-7bda2708019a'),(1172,'VL_IND-20 All VL tests performed','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-20 All VL tests performed\n \n \n 2021-08-05 13:09:38 UTC\n \n 2021-08-05 13:10: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 1172\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:39:38',4,'2021-08-05 18:40:14',4,0,NULL,NULL,NULL,'0c3d2e85-47de-4f40-8213-d9a20d690f1a'),(1173,'VL_IND-21 Suppressed VL tests performed','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-21 Suppressed VL tests performed\n \n \n 2021-08-05 13:11:26 UTC\n \n 2021-08-05 13:12: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 1173\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:41:26',4,'2021-08-05 18:42:12',4,0,NULL,NULL,NULL,'665dfb44-ae19-481f-9caf-51cedb3e9623'),(1174,'VL_IND-22 Detectable VL tests performed','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-22 Detectable VL tests performed\n \n \n 2021-08-05 13:13:35 UTC\n \n 2021-08-05 13:14: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 1174\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:43:35',4,'2021-08-05 18:44:46',4,0,NULL,NULL,NULL,'b459f37f-41a8-468e-93f9-f3b91ec6baf5'),(1175,'Viral Load Progress Report','Viral Load Progress Report ->Routine VL tests performed, Targeted VL tests performed, Routine suppressed VL tests results, Routine detectable VL tests results, Breastfeeding mothers VL tests performed, Breastfeeding mothers detectable VL test results, Breastfeeding mothers suppressed VL test results, Pregnant women VL tests performed, Pregnant women detectable VL test results, Pregnant women suppressed VL test results','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Viral Load Progress Report\n Viral Load Progress Report ->Routine VL tests performed, Targeted VL tests performed, Routine suppressed VL tests results, Routine detectable VL tests results, Breastfeeding mothers VL tests performed, Breastfeeding mothers detectable VL test results, Breastfeeding mothers suppressed VL test results, Pregnant women VL tests performed, Pregnant women detectable VL test results, Pregnant women suppressed VL test results\n \n 2021-08-05 13:16:28 UTC\n \n 2021-08-05 13:16: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 1175\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','2021-08-05 18:46:28',4,'2021-08-05 18:46:35',4,0,NULL,NULL,NULL,'7b0e0a97-0012-43e7-8a1b-79d4812c2562'),(1176,'Viral Load Progress 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 Viral Load Progress Report Data Set\n \n 2021-08-05 13:16:35 UTC\n \n 2021-08-09 20:10: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 1176\n \n \n DM_Sex\n \n \n \n \n \n \n DM_VL_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n breas_dete\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 breas_perf\n \n \n \n \n \n \n \n \n \n breas_supp\n \n \n \n \n \n \n \n \n \n preg_detec\n \n \n \n \n \n \n \n \n \n preg_perfr\n \n \n \n \n \n \n \n \n \n preg_suppr\n \n \n \n \n \n \n \n \n \n rout_detec\n \n \n \n \n \n \n \n \n \n rout_suppr\n \n \n \n \n \n \n \n \n \n routin_per\n \n \n \n \n \n \n \n \n \n targ_detec\n \n \n \n \n \n \n \n \n \n targ_perf\n \n \n \n \n \n \n \n \n \n targ_suppr\n \n \n \n \n \n \n \n \n \n','2021-08-05 15:16:35',4,'2021-08-09 22:10:25',4,0,NULL,NULL,NULL,'d93606e1-d4e9-4cff-9377-7a6eb5342a56'),(1177,'Viral Load Progress Report, Age and Sex','','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Viral Load Progress Report, Age and Sex\n \n \n 2021-08-05 13:31:16 UTC\n \n 2021-08-05 13:31: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 1177\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','2021-08-05 19:01:16',4,'2021-08-05 19:01:23',4,0,NULL,NULL,NULL,'0ce6c29e-4969-448c-9607-b4485b2ec729'),(1178,'Viral Load Progress Report, Age and Sex Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Viral Load Progress Report, Age and Sex Data Set\n \n 2021-08-05 13:31:23 UTC\n \n 2021-08-09 20:20: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 1178\n \n \n DM_Sex\n \n \n \n \n \n \n DM_VL_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 1-4yrsF_De\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_VL_Age\n 1-4yrs\n \n \n \n \n \n 1-4yrsF_su\n \n \n \n \n \n \n \n \n \n 1-4yrsF_vl\n \n \n \n \n \n \n \n \n \n 1-4yrsM_De\n \n \n \n \n DM_Sex\n Males\n \n \n DM_VL_Age\n 1-4yrs\n \n \n \n \n \n 1-4yrsM_su\n \n \n \n \n \n \n 1-4yrsM_vl\n \n \n \n \n \n \n 5-14yrsF_D\n \n \n \n \n DM_Sex\n Females\n \n \n DM_VL_Age\n 5-14yrs\n \n \n \n \n \n 5-14yrsF_s\n \n \n \n \n \n \n 5-14yrsF_v\n \n \n \n \n \n \n 5-14yrsM_D\n \n \n \n \n DM_Sex\n Males\n \n \n DM_VL_Age\n 5-14yrs\n \n \n \n \n \n 5-14yrsM_s\n \n \n \n \n \n \n 5-14yrsM_v\n \n \n \n \n \n \n 15-19yF_Su\n \n \n \n \n DM_Sex\n Females\n \n \n DM_VL_Age\n 15-19yrs\n \n \n \n \n \n 15-19yM_Su\n \n \n \n \n DM_Sex\n Males\n \n \n DM_VL_Age\n 15-19yrs\n \n \n \n \n \n 15-19yrF_D\n \n \n \n \n \n \n 15-19yrM_D\n \n \n \n \n \n \n 15-19yrsF\n \n \n \n \n \n \n 15-19yrsM\n \n \n \n \n \n \n 20+yrsF_De\n \n \n \n \n DM_Sex\n Females\n \n \n DM_VL_Age\n 20+\n \n \n \n \n \n 20+yrsF_Su\n \n \n \n \n \n \n 20+yrsF_vl\n \n \n \n \n \n \n 20+yrsM_De\n \n \n \n \n DM_Sex\n Males\n \n \n DM_VL_Age\n 20+\n \n \n \n \n \n 20+yrsM_Su\n \n \n \n \n \n \n 20+yrsM_vl\n \n \n \n \n \n \n <1yrsF_Dec\n \n \n \n \n DM_Sex\n Females\n \n \n DM_VL_Age\n Under 1yr\n \n \n \n \n \n <1yrsF_sup\n \n \n \n \n \n \n <1yrsF_vl\n \n \n \n \n \n \n <1yrsM_Dec\n \n \n \n \n DM_Sex\n Males\n \n \n DM_VL_Age\n Under 1yr\n \n \n \n \n \n <1yrsM_sup\n \n \n \n \n \n \n <1yrsM_vl\n \n \n \n \n \n \n','2021-08-05 15:31:23',4,'2021-08-09 22:20:22',4,0,NULL,NULL,NULL,'e4248881-990d-43ff-ad99-8f95eb362fe9'),(1179,'VL-21 Clients with pending VL test results, within 1 month','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-21 Clients with pending VL test results, within 1 month\n \n \n 2021-08-17 19:08:16 UTC\n \n 2024-02-06 09:10: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 1179\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nwhere o.concept_id = 5494 \n and datediff(cast(o.value_datetime as date), date(date_add(:endDate, interval -1 month))) between 0 and 30 \n and (o.location_id = :location or parent_location = :location) \n and o.voided = 0 \n and o.person_id not in ( \n select distinct os.person_id \n from obs os \n where os.concept_id in (5485,5489) \n and datediff(cast(os.value_datetime as date), date(date_add(:endDate, interval -1 month))) between 0 and 30 \n and o.encounter_id = os.encounter_id \n and os.voided = 0 \n )\n','2021-08-18 00:38:16',4,'2024-02-06 14:40:21',4,0,NULL,NULL,NULL,'3520025c-2f9f-49df-9c87-8a50b0643a54'),(1180,'VL-20 Clients with pending VL test results, within 2 months','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-20 Clients with pending VL test results, within 2 months\n \n \n 2021-08-17 19:12:21 UTC\n \n 2024-02-06 09:12: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 1180\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.concept_id = 5494 \n and datediff(cast(o.value_datetime as date), date(date_add(:endDate, interval -2 month))) between 30 and 60 \n and (o.location_id = :location or parent_location = :location) \n and o.voided = 0 \n and o.person_id not in ( \n select distinct os.person_id \n from obs os \n where os.concept_id in (5485,5489) \n and datediff(cast(os.value_datetime as date), date(date_add(:endDate, interval -2 month))) between 30 and 60 \n and o.encounter_id = os.encounter_id \n and os.voided = 0 \n )\n','2021-08-18 00:42:21',4,'2024-02-06 14:42:40',4,0,NULL,NULL,NULL,'c0967c50-bf72-4423-b3da-97449ab7fa0b'),(1181,'VL-17 Clients with pending VL test results, within 3 months','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-17 Clients with pending VL test results, within 3 months\n \n \n 2021-08-17 19:15:26 UTC\n \n 2024-02-06 09:15: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 1181\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nwhere o.concept_id = 5494 \n and datediff(cast(o.value_datetime as date), date(date_add(:endDate, interval -3 month))) between 60 and 90 \n and (o.location_id = :location or parent_location = :location) \n and o.voided = 0 \n and o.person_id not in ( \n select distinct os.person_id \n from obs os \n where os.concept_id in (5485,5489) \n and datediff(cast(os.value_datetime as date), date(date_add(:endDate, interval -3 month))) between 60 and 90 \n and o.encounter_id = os.encounter_id \n and os.voided = 0 \n )\n','2021-08-18 00:45:26',4,'2024-02-06 14:45:18',4,0,NULL,NULL,NULL,'7d9263e2-ce8a-4d73-a2f5-b521f926d68f'),(1183,'VL-18 Clients with VL results received within 3 months','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-18 Clients with VL results received within 3 months\n \n \n 2021-08-17 19:21:11 UTC\n \n 2024-02-06 09: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 1183\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nwhere o.concept_id = 5494 \n and datediff(cast(o.value_datetime as date), date(date_add(:endDate, interval -3 month))) between 0 and 90 \n and (o.location_id = :location or parent_location = :location) \n and o.voided = 0 \n and o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id in (5485, 5489) \n and datediff(cast(os.value_datetime as date), date(date_add(:endDate, interval -3 month))) between 0 and 90 \n and os.encounter_id = os.encounter_id \n and os.voided = 0 \n )\n','2021-08-18 00:51:11',4,'2024-02-06 14:36:12',4,0,NULL,NULL,NULL,'f0ce5eac-eccc-4e50-95fb-58d508882be7'),(1184,'VL-16 Clients with blood drawn for VL tests in recent 3 months','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-16 Clients with blood drawn for VL tests in recent 3 months\n \n \n 2021-08-17 19:25:37 UTC\n \n 2024-02-06 08:55: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 1184\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nwhere o.concept_id = 5494 \n and datediff(o.value_datetime, date(date_add(cast(:endDate as date), interval -3 month))) between 0 and 90 \n and (o.location_id = :location or parent_location = :location) \n and o.voided = 0\n','2021-08-18 00:55:37',4,'2024-02-06 14:25:00',4,0,NULL,NULL,NULL,'086fb891-06bb-43b1-827f-ef9e1a2f1216'),(1185,'VL_IND-13 Clients with pending VL test results, within 1 month','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-13 Clients with pending VL test results, within 1 month\n \n \n 2021-08-17 19:35:14 UTC\n \n 2021-08-17 19: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 1185\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-17 21:35:14',4,'2021-08-17 21:41:15',4,0,NULL,NULL,NULL,'21817a2d-3999-47ec-9e07-44cd74686206'),(1186,'VL_IND-14 Clients with pending VL test results, within 2 months','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-14 Clients with pending VL test results, within 2 months\n \n \n 2021-08-17 19:42:46 UTC\n \n 2021-08-17 19:49: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 1186\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-17 21:42:46',4,'2021-08-17 21:49:46',4,0,NULL,NULL,NULL,'ddec73ad-0c9c-4c53-b7e2-8fedde3c8a2b'),(1187,'VL_IND-15 Clients with pending VL test results, within 3 months','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-15 Clients with pending VL test results, within 3 months\n \n \n 2021-08-17 19:51:42 UTC\n \n 2021-08-17 19:56: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 1187\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-17 21:51:42',4,'2021-08-17 21:56:04',4,0,NULL,NULL,NULL,'5f5b4341-c279-4cd9-96c9-ec727cccc733'),(1188,'VL_IND-16 Clients with blood drawn for VL tests in recent 3 months','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-16 Clients with blood drawn for VL tests in recent 3 months\n \n \n 2021-08-17 19:57:58 UTC\n \n 2021-08-17 19:59: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 1188\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-17 21:57:58',4,'2021-08-17 21:59:21',4,0,NULL,NULL,NULL,'81898c9b-878a-4cf5-ad51-c3190878f2c3'),(1189,'VL_IND-17 Clients with VL results received within 3 months','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-17 Clients with VL results received within 3 months\n \n \n 2021-08-17 20:00:16 UTC\n \n 2021-08-17 20: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 1189\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-17 22:00:16',4,'2021-08-17 22:00:58',4,0,NULL,NULL,NULL,'981a63bf-3e3d-49b6-9ff9-251508dc6d5e'),(1191,'Weekly Viral Load Report','','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Weekly Viral Load Report\n \n \n 2021-08-17 20:12:39 UTC\n \n 2021-08-17 20:12: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 1191\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','2021-08-17 22:12:39',4,'2021-08-17 22:12:46',4,0,NULL,NULL,NULL,'eab176b2-ffbc-43b1-8d96-1fc703df2009'),(1192,'Weekly Viral Load 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 Weekly Viral Load Report Data Set\n \n 2021-08-17 20:12:46 UTC\n \n 2021-08-17 20: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 1192\n \n \n \n VL_BD_3M\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 VL_Res_3M\n \n \n \n \n \n \n \n \n \n VL_Res_CM\n \n \n \n \n \n \n \n \n \n VL_Rs_P_1M\n \n \n \n \n \n \n \n \n \n VL_Rs_P_2M\n \n \n \n \n \n \n \n \n \n VL_Rs_P_3M\n \n \n \n \n \n \n \n \n \n','2021-08-17 22:12:46',4,'2021-08-17 22:27:22',4,0,NULL,NULL,NULL,'637a51c0-da3c-4ce0-a904-8c1b6d02f7ee'),(1193,'PIR-17 Tx_CURR Retention Report','','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR-17 Tx_CURR Retention Report\n \n \n 2021-09-17 02:00:37 UTC\n \n 2021-09-17 02:00: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 1193\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','2021-09-17 04:00:37',4,'2021-09-17 04:00:45',4,0,NULL,NULL,NULL,'7acdbe71-cb34-40fc-839e-ff902abd9aaa'),(1194,'PIR-17 Tx_CURR Retention 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 PIR-17 Tx_CURR Retention Report Data Set\n \n 2021-09-17 02:00:45 UTC\n \n 2022-08-24 09:26: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 1194\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n MMDF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n MMDF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n MMDF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n MMDF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n MMDF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n MMDF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n MMDF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n MMDF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n MMDF45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n MMDF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n MMDF50\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n MMDF<1yr\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n MMDM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n MMDM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n MMDM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n MMDM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n MMDM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n MMDM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n MMDM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n MMDM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n MMDM45-49\n \n \n \n \n \n \n MMDM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n MMDM50\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n MMDM<1yr\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n R_IIT<3F1-\n \n \n \n \n \n \n \n \n \n R_IIT<3F10\n \n \n \n \n \n \n R_IIT<3F15\n \n \n \n \n \n \n R_IIT<3F20\n \n \n \n \n \n \n R_IIT<3F25\n \n \n \n \n \n \n R_IIT<3F30\n \n \n \n \n \n \n R_IIT<3F35\n \n \n \n \n \n \n R_IIT<3F40\n \n \n \n \n \n \n R_IIT<3F45\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n R_IIT<3F5-\n \n \n \n \n \n \n R_IIT<3F50\n \n \n \n \n \n \n R_IIT<3F<1\n \n \n \n \n \n \n R_IIT<3M1-\n \n \n \n \n \n \n R_IIT<3M10\n \n \n \n \n \n \n R_IIT<3M15\n \n \n \n \n \n \n R_IIT<3M20\n \n \n \n \n \n \n R_IIT<3M25\n \n \n \n \n \n \n R_IIT<3M30\n \n \n \n \n \n \n R_IIT<3M35\n \n \n \n \n \n \n R_IIT<3M40\n \n \n \n \n \n \n R_IIT<3M45\n \n \n \n \n \n \n R_IIT<3M5-\n \n \n \n \n \n \n R_IIT<3M50\n \n \n \n \n \n \n R_IIT<3M<1\n \n \n \n \n \n \n RIIT3-5F1-\n \n \n \n \n \n \n \n \n \n RIIT3-5F10\n \n \n \n \n \n \n RIIT3-5F15\n \n \n \n \n \n \n RIIT3-5F20\n \n \n \n \n \n \n RIIT3-5F25\n \n \n \n \n \n \n RIIT3-5F30\n \n \n \n \n \n \n RIIT3-5F35\n \n \n \n \n \n \n RIIT3-5F40\n \n \n \n \n \n \n RIIT3-5F45\n \n \n \n \n \n \n RIIT3-5F5-\n \n \n \n \n \n \n RIIT3-5F50\n \n \n \n \n \n \n RIIT3-5F<1\n \n \n \n \n \n \n RIIT3-5M1-\n \n \n \n \n \n \n RIIT3-5M10\n \n \n \n \n \n \n RIIT3-5M15\n \n \n \n \n \n \n RIIT3-5M20\n \n \n \n \n \n \n RIIT3-5M25\n \n \n \n \n \n \n RIIT3-5M30\n \n \n \n \n \n \n RIIT3-5M35\n \n \n \n \n \n \n RIIT3-5M40\n \n \n \n \n \n \n RIIT3-5M45\n \n \n \n \n \n \n RIIT3-5M5-\n \n \n \n \n \n \n RIIT3-5M50\n \n \n \n \n \n \n RIIT3-5M<1\n \n \n \n \n \n \n RIIT6pF1-4\n \n \n \n \n \n \n \n \n \n RIIT6pF10-\n \n \n \n \n \n \n RIIT6pF15-\n \n \n \n \n \n \n RIIT6pF20-\n \n \n \n \n \n \n RIIT6pF25-\n \n \n \n \n \n \n RIIT6pF30-\n \n \n \n \n \n \n RIIT6pF35-\n \n \n \n \n \n \n RIIT6pF40-\n \n \n \n \n \n \n RIIT6pF45-\n \n \n \n \n \n \n RIIT6pF5-9\n \n \n \n \n \n \n RIIT6pF50-\n \n \n \n \n \n \n RIIT6pF<1\n \n \n \n \n \n \n RIIT6pM1-4\n \n \n \n \n \n \n RIIT6pM10-\n \n \n \n \n \n \n RIIT6pM15-\n \n \n \n \n \n \n RIIT6pM20-\n \n \n \n \n \n \n RIIT6pM25-\n \n \n \n \n \n \n RIIT6pM30-\n \n \n \n \n \n \n RIIT6pM35-\n \n \n \n \n \n \n RIIT6pM40-\n \n \n \n \n \n \n RIIT6pM45-\n \n \n \n \n \n \n RIIT6pM5-9\n \n \n \n \n \n \n RIIT6pM50-\n \n \n \n \n \n \n RIIT6pM<1\n \n \n \n \n \n \n SeenF1-4\n \n \n \n \n \n \n \n \n \n SeenF10-14\n \n \n \n \n \n \n SeenF15-19\n \n \n \n \n \n \n SeenF20-24\n \n \n \n \n \n \n SeenF25-29\n \n \n \n \n \n \n SeenF30-34\n \n \n \n \n \n \n SeenF35-39\n \n \n \n \n \n \n SeenF40-44\n \n \n \n \n \n \n SeenF45-49\n \n \n \n \n \n \n SeenF5-9\n \n \n \n \n \n \n SeenF50\n \n \n \n \n \n \n SeenF<1yr\n \n \n \n \n \n \n SeenM1-4\n \n \n \n \n \n \n SeenM10-14\n \n \n \n \n \n \n SeenM15-19\n \n \n \n \n \n \n SeenM20-24\n \n \n \n \n \n \n SeenM25-29\n \n \n \n \n \n \n SeenM30-34\n \n \n \n \n \n \n SeenM35-39\n \n \n \n \n \n \n SeenM40-44\n \n \n \n \n \n \n SeenM45-49\n \n \n \n \n \n \n SeenM5-9\n \n \n \n \n \n \n SeenM50\n \n \n \n \n \n \n SeenM<1yr\n \n \n \n \n \n \n T/InF1-4\n \n \n \n \n \n \n \n \n \n T/InF10-14\n \n \n \n \n \n \n T/InF15-19\n \n \n \n \n \n \n T/InF20-24\n \n \n \n \n \n \n T/InF25-29\n \n \n \n \n \n \n T/InF30-34\n \n \n \n \n \n \n T/InF35-39\n \n \n \n \n \n \n T/InF40-44\n \n \n \n \n \n \n T/InF45-49\n \n \n \n \n \n \n T/InF5-9\n \n \n \n \n \n \n T/InF50\n \n \n \n \n \n \n T/InF<1yr\n \n \n \n \n \n \n T/InM1-4\n \n \n \n \n \n \n T/InM10-14\n \n \n \n \n \n \n T/InM15-19\n \n \n \n \n \n \n T/InM20-24\n \n \n \n \n \n \n T/InM25-29\n \n \n \n \n \n \n T/InM30-34\n \n \n \n \n \n \n T/InM35-39\n \n \n \n \n \n \n T/InM40-44\n \n \n \n \n \n \n T/InM45-49\n \n \n \n \n \n \n T/InM5-9\n \n \n \n \n \n \n T/InM50\n \n \n \n \n \n \n T/InM<1yr\n \n \n \n \n \n \n','2021-09-17 02:00:45',4,'2022-08-24 09:26:32',4,0,NULL,NULL,NULL,'44c35489-bda8-422a-abd6-239ec4495167'),(1195,'TX_ML-01 Clients who are current on ART at reporting period and experienced IIT_Died','TX_ML-01 Clients who are current on ART at reporting period and experienced IIT_Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_ML-01 Clients who are current on ART at reporting period and experienced IIT_Died\n TX_ML-01 Clients who are current on ART at reporting period and experienced IIT_Died\n \n 2021-09-17 02:02:13 UTC\n \n 2024-02-15 08: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 endDateas\n \n java.util.Date\n true\n \n \n 1195\n select obs_ml_clients.person_id \nfrom obs os \ninner join location l on os.location_id = l.location_id \ninner join \n( \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) < 29) as On_ART_Beginning_Quarter \n ) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n UNION \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 2249 and cast(o.value_datetime as date) >= cast(:startDate as DATE) and cast(o.value_datetime as date) <= cast(:endDate as DATE) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n) as obs_ml_clients on os.person_id = obs_ml_clients.person_id \nINNER JOIN person ON person.person_id = obs_ml_clients.person_id AND person.voided = 0 \nINNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \nWHERE os.location_id =:location or parent_location =:location \n AND obs_ml_clients.person_id in ( \n select person_id \n from person \n where death_date <= CAST(:endDate AS DATE) \n and dead = 1 \n ) \nAND obs_ml_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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n )\n','2021-09-17 07:32:13',4,'2024-02-15 14:06:30',4,0,NULL,NULL,NULL,'8d2c7d4f-adbf-4aa0-bd9e-e19ce887a64f'),(1196,'TX_ML-02 Clients who are current on ART at reporting period and experienced IIT<3months','TX_ML-02 Clients who are current on ART at reporting period and experienced IIT<3months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_ML-02 Clients who are current on ART at reporting period and experienced IIT<3months\n TX_ML-02 Clients who are current on ART at reporting period and experienced IIT<3months\n \n 2021-09-17 02:02:54 UTC\n \n 2024-02-15 08:37: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 1196\n select obs_ml_clients.person_id \nfrom obs os \ninner join location l on os.location_id = l.location_id \ninner join \n( \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) < 29) as On_ART_Beginning_Quarter \n ) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n UNION \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 2249 and cast(o.value_datetime as date) >= cast(:startDate as DATE) and cast(o.value_datetime as date) <= cast(:endDate as DATE) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n) as obs_ml_clients on os.person_id = obs_ml_clients.person_id \nINNER JOIN person ON person.person_id = obs_ml_clients.person_id AND person.voided = 0 \nINNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \nWHERE os.location_id =:location or parent_location =:location \n -- INITIATED ON ART LESS THAN 3 MONTHS AGO \n AND obs_ml_clients.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 2249 \n AND datediff(CAST(:endDate AS DATE), os.value_datetime) BETWEEN 0 AND 90 \n ) \n -- NOT Transfered Out to Another Site \n AND obs_ml_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 4155 and os.value_coded = 2146 \n AND os.obs_datetime <= CAST(:endDate AS DATE) \n ) \n -- NOT DEAD \n AND obs_ml_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 ) \nAND obs_ml_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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n )\n','2021-09-17 07:32:54',4,'2024-02-15 14:07:28',4,0,NULL,NULL,NULL,'ed95842b-5f50-4afe-89c1-b1761191123e'),(1197,'TX_ML-03 Clients who are current on ART at reporting period and experienced IIT_6+months','TX_ML-03 Clients who are current on ART at reporting period and experienced IIT_6+months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_ML-03 Clients who are current on ART at reporting period and experienced IIT_6+months\n TX_ML-03 Clients who are current on ART at reporting period and experienced IIT_6+months\n \n 2021-09-17 02:04:20 UTC\n \n 2024-02-15 08:44: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 1197\n select obs_ml_clients.person_id \nfrom obs os \ninner join location l on os.location_id = l.location_id \ninner join \n( \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) < 29) as On_ART_Beginning_Quarter \n ) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n UNION \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 2249 and cast(o.value_datetime as date) >= cast(:startDate as DATE) and cast(o.value_datetime as date) <= cast(:endDate as DATE) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n) as obs_ml_clients on os.person_id = obs_ml_clients.person_id \nINNER JOIN person ON person.person_id = obs_ml_clients.person_id AND person.voided = 0 \nINNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \nWHERE os.location_id =:location or parent_location =:location \n -- INITIATED ON ART MORE THAN 3 MONTHS AGO \n AND obs_ml_clients.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 2249 \n AND datediff(CAST(:endDate AS DATE), os.value_datetime) >= 180 \n ) \n -- NOT Transfered Out to Another Site \n AND obs_ml_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 4155 and os.value_coded = 2146 \n AND os.obs_datetime <= CAST(:endDate AS DATE) \n ) \n -- NOT DEAD \n AND obs_ml_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 ) \nAND obs_ml_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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n )\n','2021-09-17 07:34:20',4,'2024-02-15 14:14:36',4,0,NULL,NULL,NULL,'11fdf33c-0d64-4c86-8ece-f8eb55ed6119'),(1198,'TX_ML-04 Clients who are current on ART at reporting period and experienced IIT_TOut','TX_ML-04 Clients who are current on ART at reporting period and experienced IIT_TOut','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_ML-04 Clients who are current on ART at reporting period and experienced IIT_TOut\n TX_ML-04 Clients who are current on ART at reporting period and experienced IIT_TOut\n \n 2021-09-17 02:05:17 UTC\n \n 2024-02-15 09:01: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 endDateas\n \n java.util.Date\n true\n \n \n 1198\n select obs_ml_clients.person_id \nfrom obs os \ninner join location l on os.location_id = l.location_id \ninner join \n( \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) < 1) as On_ART_Beginning_Quarter \n ) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 0) as Missed_Greater_Than_0Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n UNION \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 2249 and cast(o.value_datetime as date) >= cast(:startDate as DATE) and cast(o.value_datetime as date) <= cast(:endDate as DATE) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 0) as Missed_Greater_Than_0Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n) as obs_ml_clients on os.person_id = obs_ml_clients.person_id \nINNER JOIN person ON person.person_id = obs_ml_clients.person_id AND person.voided = 0 \nINNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \nWHERE os.location_id =:location or parent_location =:location \n -- Transfered Out to Another Site \n AND obs_ml_clients.person_id in ( \n \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 -- NOT DEAD \n AND obs_ml_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 AND obs_ml_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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n )\n','2021-09-17 07:35:17',4,'2024-02-15 14:31:14',4,0,NULL,NULL,NULL,'d19bded0-5e8e-4aeb-a41f-f5c6921d90a9'),(1199,'TX_ML-05 Clients who are current on ART at reporting period and experienced IIT_Stopped','TX_ML-05 Clients who are current on ART at reporting period and experienced IIT_Stopped','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_ML-05 Clients who are current on ART at reporting period and experienced IIT_Stopped\n TX_ML-05 Clients who are current on ART at reporting period and experienced IIT_Stopped\n \n 2021-09-17 02:06:20 UTC\n \n 2024-02-15 09:02: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 1199\n select obs_ml_clients.person_id \nfrom obs os \ninner join location l on os.location_id = l.location_id \ninner join \n( \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) < 29) as On_ART_Beginning_Quarter \n ) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n UNION \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 2249 and cast(o.value_datetime as date) >= cast(:startDate as DATE) and cast(o.value_datetime as date) <= cast(:endDate as DATE) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n) as obs_ml_clients on os.person_id = obs_ml_clients.person_id \nINNER JOIN person ON person.person_id = obs_ml_clients.person_id AND person.voided = 0 \nINNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \nWHERE os.location_id =:location or parent_location =:location \n -- ART TREATMENT INTERRUPTION/REFUSED OR STOPPED \n AND obs_ml_clients.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 3701 \n AND os.value_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \nAND obs_ml_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 ) \nAND obs_ml_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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n )\n','2021-09-17 07:36:20',4,'2024-02-15 14:32:17',4,0,NULL,NULL,NULL,'436959a2-8534-4a1e-9e76-3baf516b8620'),(1200,'TX_RTT-01 Clients with IIT in previous period who restarted ARV\'s during current period','TX_RTT-01 Clients with IIT in previous period who restarted ARV\'s during current period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_RTT-01 Clients with IIT in previous period who restarted ARV's during current period\n TX_RTT-01 Clients with IIT in previous period who restarted ARV's during current period\n \n 2021-09-17 02:07:07 UTC\n \n 2021-09-17 02:07: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 1200\n select distinct o.person_id \nfrom obs o \n-- PATIENTS WITH NO CLINICAL CONTACT OR ARV PICK-UP FOR GREATER THAN 28 DAYS \n-- SINCE THEIR LAST EXPECTED CONTACT WHO RESTARTED ARVs WITHIN THE REPORTING PERIOD \ninner join location l on o.location_id = l.location_id \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND patient.voided = 0 AND o.voided = 0 \nAND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n \n -- Client Seen: As either patient OR Treatment Buddy \n AND ( \n o.person_id 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 os.obs_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n \n -- Client Seen and Date Restarted picked \n OR o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 3708 AND os.value_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n ) \n -- Still on treatment at the end of the reporting period \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime >= cast(:startDate as DATE) and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) <= 28) as Still_On_Treatment_End_Period \n ) \n \n -- Transfered Out to Another Site during thier latest encounter before the start date \n AND o.person_id not in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS last_obs_tout \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 4155 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having last_obs_tout = 2146) as Transfered_Out_In_Last_Encounter \n ) \n \n-- NOT Transfered In from another Site \n AND o.person_id not in ( \n select os.person_id \n from obs os \n where (os.concept_id = 2253 AND DATE(os.value_datetime) BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE)) \n AND os.voided = 0 \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 \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 \nWHERE (o.location_id =:location or parent_location =:location)\n','2021-09-17 04:07:07',4,'2021-09-17 04:07:22',4,0,NULL,NULL,NULL,'2ada18e8-c557-4e96-ac65-84648ec56b7f'),(1201,'Continuation ART Clients Seen ','Continuation ART Clients Seen excl Transfers In, TxRTT','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Continuation ART Clients Seen \n Continuation ART Clients Seen excl Transfers In, TxRTT\n \n 2021-09-17 02:08:18 UTC\n \n 2021-09-17 02:09: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 1201\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 \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 CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH) \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 NEWLY 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(:startDate AS DATE)) \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 ) \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(:startDate AS DATE) \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 -3 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 \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(:startDate AS DATE) \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 -3 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 ) \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 ) \n ) \n \n-- Exclude Transfers In \nAND Clients_Seen.Id not in ( \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON patient.patient_id = person.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 where concept_id = 3634 and o.value_coded = 2095 \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 CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH) \n and o.voided = 0) \n \n \nAND Clients_Seen.Id not in ( \n \nselect distinct (o.person_id) \nfrom obs o \n-- PATIENTS WITH NO CLINICAL CONTACT OR ARV PICK-UP FOR GREATER THAN 28 DAYS \n-- SINCE THEIR LAST EXPECTED CONTACT WHO RESTARTED ARVs WITHIN THE REPORTING PERIOD \n-- inner join location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON patient.patient_id = person.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 patient.voided = 0 AND o.voided = 0 \nwhere o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n \n AND ( \n o.person_id 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 os.obs_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n \n -- Client Seen and Date Restarted picked \n OR o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 3708 AND os.value_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n ) \n \n -- Still on treatment at the end of the reporting period \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime >= cast(:startDate as DATE) and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) <= 28) as Still_On_Treatment_End_Period \n ) \n \n -- Transfered Out to Another Site during thier latest encounter before the start date \n AND o.person_id not in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS last_obs_tout \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 4155 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having last_obs_tout = 2146) as Transfered_Out_In_Last_Encounter \n ) \n \n-- NOT Transfered In from another Site \n AND o.person_id not in ( \n select os.person_id \n from obs os \n where (os.concept_id = 2253 AND DATE(os.value_datetime) BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE)) \n AND os.voided = 0 \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 \n ) \n \n))\n','2021-09-17 04:08:18',4,'2021-09-17 04:09:23',4,0,NULL,NULL,NULL,'6d452652-2e45-4009-a6fc-a00231e470ce'),(1202,'Continuation ART Clients On MMD','Continuation ART Clients On MMD excl Seen, Transfers In, TxRTT','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Continuation ART Clients On MMD\n Continuation ART Clients On MMD excl Seen, Transfers In, TxRTT\n \n 2021-09-17 02:10:59 UTC\n \n 2021-09-17 02:11: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 1202\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 \n(SELECT Id \nFROM ( \n \n (SELECT Id, patientIdentifier , patientName, Age, Gender, age_group, 'Seen_Previous' AS 'Program_Status', sort_order \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.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 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 \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 CAST(os.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND CAST(os.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH) \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(:startDate AS DATE)) \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(:startDate AS DATE) \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 -3 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 and active_clients.person_id not in ( \n -- Transfers In \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON patient.patient_id = person.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 where concept_id = 3634 and o.value_coded = 2095 \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 CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH) \n and o.voided = 0 \n \n \n ) \n \n and active_clients.person_id not in ( \n \n select distinct (o.person_id) \n from obs o \n -- PATIENTS WITH NO CLINICAL CONTACT OR ARV PICK-UP FOR GREATER THAN 28 DAYS \n -- SINCE THEIR LAST EXPECTED CONTACT WHO RESTARTED ARVs WITHIN THE REPORTING PERIOD \n -- inner join location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON patient.patient_id = person.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 patient.voided = 0 AND o.voided = 0 \n where o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n \n AND ( \n o.person_id 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 os.obs_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n \n -- Client Seen and Date Restarted picked \n OR o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 3708 AND os.value_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n ) \n \n -- Still on treatment at the end of the reporting period \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime >= cast(:startDate as DATE) and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) <= 28) as Still_On_Treatment_End_Period \n ) \n \n -- Transfered Out to Another Site during thier latest encounter before the start date \n AND o.person_id not in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS last_obs_tout \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 4155 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having last_obs_tout = 2146) as Transfered_Out_In_Last_Encounter \n ) \n \n -- NOT Transfered In from another Site \n AND o.person_id not in ( \n select os.person_id \n from obs os \n where (os.concept_id = 2253 AND DATE(os.value_datetime) BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE)) \n AND os.voided = 0 \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 \n ) \n \n ) \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)AS Seen_Prev)\n','2021-09-17 04:10:59',4,'2021-09-17 04:11:17',4,0,NULL,NULL,NULL,'6c3b70a0-3830-4598-aba2-92ac32c4d52d'),(1203,'Continuation ART Clients Transferred In','Continuation ART Clients Transferred In','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Continuation ART Clients Transferred In\n Continuation ART Clients Transferred In\n \n 2021-09-17 02:12:22 UTC\n \n 2021-09-17 02:12: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 1203\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 \n(select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON patient.patient_id = person.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 where concept_id = 3634 and o.value_coded = 2095 \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 CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH) \n and o.voided = 0)\n','2021-09-17 04:12:22',4,'2021-09-17 04:12:38',4,0,NULL,NULL,NULL,'47d0abca-f9d5-48b3-9151-647a732e9a76'),(1204,'CI46: TxML Died','TxML Died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI46: TxML Died\n TxML Died\n \n 2021-09-17 02:14:41 UTC\n \n 2021-09-17 06:22: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 1204\n COUNT\n \n \n \n \n endDate\n ${}\n \n \n location\n ${}\n \n \n startDate\n ${}\n \n \n \n','2021-09-17 04:14:41',4,'2021-09-17 08:22:13',4,0,NULL,NULL,NULL,'8952b48b-2d4e-4f46-8996-b6fc498327f5'),(1205,'CI47: TxML IIT<3months','TxML IIT<3months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI47: TxML IIT<3months\n TxML IIT<3months\n \n 2021-09-17 02:16:05 UTC\n \n 2021-09-17 02:18: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 1205\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-17 04:16:05',4,'2021-09-17 04:18:12',4,0,NULL,NULL,NULL,'4b660dac-a834-406b-b06e-90944ea1eec0'),(1206,'CI48:TxML IIT_6+','TxML IIT3_6+','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI48:TxML IIT_6+\n TxML IIT3_6+\n \n 2021-09-17 02:18:56 UTC\n \n 2022-08-10 11:05: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 1206\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-17 02:18:56',4,'2022-08-10 11:05:52',4,0,NULL,NULL,NULL,'c8cca19d-b858-4d1f-8ba4-855aa09d937e'),(1207,'CI50:TxML Stopped','TxML Stopped','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI50:TxML Stopped\n TxML Stopped\n \n 2021-09-17 02:19:58 UTC\n \n 2021-09-17 02:20: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 1207\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-17 04:19:58',4,'2021-09-17 04:20:32',4,0,NULL,NULL,NULL,'d09049bb-71b1-49c2-8e3b-d99b6216278f'),(1208,'CI49:TxML Transferred Out','TxML Transferred Out','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI49:TxML Transferred Out\n TxML Transferred Out\n \n 2021-09-17 02:21:09 UTC\n \n 2021-09-17 02:21: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 1208\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-17 04:21:09',4,'2021-09-17 04:21:47',4,0,NULL,NULL,NULL,'3858c3a8-5614-4f42-b8d5-caba30f4013d'),(1209,'CI45:TxRTT','CI45:TxRTT','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI45:TxRTT\n CI45:TxRTT\n \n 2021-09-17 02:22:14 UTC\n \n 2021-09-17 02:22: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 1209\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-17 04:22:14',4,'2021-09-17 04:22:55',4,0,NULL,NULL,NULL,'c80e8686-73e9-4cd4-ad59-eab7f5045773'),(1210,'CI51:Continuation ART Clients Seen','Continuation ART Clients Seen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI51:Continuation ART Clients Seen\n Continuation ART Clients Seen\n \n 2021-09-17 02:23:46 UTC\n \n 2021-09-17 02:24: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 1210\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-17 04:23:46',4,'2021-09-17 04:24:25',4,0,NULL,NULL,NULL,'ca465d0c-322d-4d62-820d-979df9b462bc'),(1211,'CI52:Continuation ART Clients On MMD','Continuation ART Clients On MMD','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI52:Continuation ART Clients On MMD\n Continuation ART Clients On MMD\n \n 2021-09-17 02:25:01 UTC\n \n 2021-09-17 02:25: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 1211\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-17 04:25:01',4,'2021-09-17 04:25:47',4,0,NULL,NULL,NULL,'37780447-34b7-46ab-8f48-5701f6107663'),(1212,'CI53:Continuation ART Clients Transferred In','Continuation ART Clients Transferred In','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI53:Continuation ART Clients Transferred In\n Continuation ART Clients Transferred In\n \n 2021-09-17 02:27:04 UTC\n \n 2021-09-17 02:31: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 1212\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-17 04:27:04',4,'2021-09-17 04:31:06',4,0,NULL,NULL,NULL,'04fe1c76-7f90-4ac2-9c23-00651194ebaf'),(1213,'PIR-17 Tx_CURR Retention Report2','Tx_CURR Retention Report2 Aggregated','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR-17 Tx_CURR Retention Report2\n Tx_CURR Retention Report2 Aggregated\n \n 2021-09-17 05:41:13 UTC\n \n 2021-09-17 05: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 1213\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','2021-09-17 07:41:13',4,'2021-09-17 07:41:37',4,0,NULL,NULL,NULL,'0e82afa4-1875-4274-bba1-3cc7b7ba33e2'),(1214,'PIR-17 Tx_CURR Retention Report2 Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR-17 Tx_CURR Retention Report2 Data Set\n \n 2021-09-17 05:41:37 UTC\n \n 2021-09-17 06:02: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 1214\n \n \n \n TxML Died\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 Cont-MMD\n \n \n \n \n \n \n \n \n \n Cont-Seen\n \n \n \n \n \n \n \n \n \n Cont-T/In\n \n \n \n \n \n \n \n \n \n TxML IIT<3\n \n \n \n \n \n \n \n \n \n TxML IIT>3\n \n \n \n \n \n \n \n \n \n TxML Stopp\n \n \n \n \n \n \n \n \n \n TxML T/Out\n \n \n \n \n \n \n \n \n \n TxRTT\n \n \n \n \n \n \n \n \n \n','2021-09-17 07:41:37',4,'2021-09-17 08:02:25',4,0,NULL,NULL,NULL,'046b6e02-8095-4280-bd2d-a729548a2a0a'),(1215,'PIR-17 Tx_CURR TXML','TXML Report including Died,IIT<3months, IIT3-5months,IIT6+months,Transferred Out, Stopped','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR-17 Tx_CURR TXML\n TXML Report including Died,IIT<3months, IIT3-5months,IIT6+months,Transferred Out, Stopped\n \n 2021-09-21 10:52:46 UTC\n \n 2022-08-30 09:40: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 1215\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','2021-09-21 10:52:46',4,'2022-08-30 09:40:54',4,0,NULL,NULL,NULL,'a8849fa6-fe2a-4273-bd0b-c284635ed6c2'),(1216,'PIR-17 Tx_CURR TXML Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR-17 Tx_CURR TXML Data Set\n \n 2021-09-21 10:52:57 UTC\n \n 2022-09-23 08:18: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 1216\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n DiedF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n DiedF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n DiedF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n DiedF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n DiedF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n DiedF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n DiedF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n DiedF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n DiedF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n DiedF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n DiedF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n DiedF<1yr\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n DiedM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n DiedM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n DiedM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n DiedM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n DiedM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n DiedM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n DiedM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n DiedM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n DiedM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n DiedM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n DiedM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n DiedM<1yr\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n IIT3-5F1-4\n \n \n \n \n \n \n \n \n \n IIT3-5F10-\n \n \n \n \n \n \n IIT3-5F15-\n \n \n \n \n \n \n IIT3-5F20-\n \n \n \n \n \n \n IIT3-5F25-\n \n \n \n \n \n \n IIT3-5F30-\n \n \n \n \n \n \n IIT3-5F35-\n \n \n \n \n \n \n IIT3-5F40-\n \n \n \n \n \n \n IIT3-5F45-\n \n \n \n \n \n \n IIT3-5F5-9\n \n \n \n \n \n \n IIT3-5F50-\n \n \n \n \n \n \n IIT3-5F<1\n \n \n \n \n \n \n IIT3-5M1-4\n \n \n \n \n \n \n IIT3-5M10-\n \n \n \n \n \n \n IIT3-5M15-\n \n \n \n \n \n \n IIT3-5M20-\n \n \n \n \n \n \n IIT3-5M25-\n \n \n \n \n \n \n IIT3-5M30-\n \n \n \n \n \n \n IIT3-5M35-\n \n \n \n \n \n \n IIT3-5M40-\n \n \n \n \n \n \n IIT3-5M45-\n \n \n \n \n \n \n IIT3-5M5-9\n \n \n \n \n \n \n IIT3-5M50p\n \n \n \n \n \n \n IIT3-5M<1\n \n \n \n \n \n \n IIT6pF1-4\n \n \n \n \n \n \n \n \n \n IIT6pF10-1\n \n \n \n \n \n \n IIT6pF15-1\n \n \n \n \n \n \n IIT6pF20-2\n \n \n \n \n \n \n IIT6pF25-2\n \n \n \n \n \n \n IIT6pF30-3\n \n \n \n \n \n \n IIT6pF35-3\n \n \n \n \n \n \n IIT6pF40-4\n \n \n \n \n \n \n IIT6pF45-4\n \n \n \n \n \n \n IIT6pF5-9\n \n \n \n \n \n \n IIT6pF50Pl\n \n \n \n \n \n \n IIT6pF<1yr\n \n \n \n \n \n \n IIT6pM1-4\n \n \n \n \n \n \n IIT6pM10-1\n \n \n \n \n \n \n IIT6pM15-1\n \n \n \n \n \n \n IIT6pM20-2\n \n \n \n \n \n \n IIT6pM25-2\n \n \n \n \n \n \n IIT6pM30-3\n \n \n \n \n \n \n IIT6pM35-3\n \n \n \n \n \n \n IIT6pM40-4\n \n \n \n \n \n \n IIT6pM45-4\n \n \n \n \n \n \n IIT6pM5-9\n \n \n \n \n \n \n IIT6pM50Pl\n \n \n \n \n \n \n IIT6pM<1yr\n \n \n \n \n \n \n IIT<3F1-4\n \n \n \n \n \n \n \n \n \n IIT<3F10-1\n \n \n \n \n \n \n IIT<3F15-1\n \n \n \n \n \n \n IIT<3F20-2\n \n \n \n \n \n \n IIT<3F25-2\n \n \n \n \n \n \n IIT<3F30-3\n \n \n \n \n \n \n IIT<3F35-3\n \n \n \n \n \n \n IIT<3F40-4\n \n \n \n \n \n \n IIT<3F45-4\n \n \n \n \n \n \n IIT<3F5-9\n \n \n \n \n \n \n IIT<3F50Pl\n \n \n \n \n \n \n IIT<3F<1yr\n \n \n \n \n \n \n IIT<3M1-4\n \n \n \n \n \n \n IIT<3M10-1\n \n \n \n \n \n \n IIT<3M15-1\n \n \n \n \n \n \n IIT<3M20-2\n \n \n \n \n \n \n IIT<3M25-2\n \n \n \n \n \n \n IIT<3M30-3\n \n \n \n \n \n \n IIT<3M35-3\n \n \n \n \n \n \n IIT<3M40-4\n \n \n \n \n \n \n IIT<3M45-4\n \n \n \n \n \n \n IIT<3M5-9\n \n \n \n \n \n \n IIT<3M50Pl\n \n \n \n \n \n \n IIT<3M<1yr\n \n \n \n \n \n \n StopF1-4\n \n \n \n \n \n \n \n \n \n StopF10-14\n \n \n \n \n \n \n StopF15-19\n \n \n \n \n \n \n StopF20-24\n \n \n \n \n \n \n StopF25-29\n \n \n \n \n \n \n StopF30-34\n \n \n \n \n \n \n StopF35-39\n \n \n \n \n \n \n StopF40-44\n \n \n \n \n \n \n StopF45-49\n \n \n \n \n \n \n StopF5-9\n \n \n \n \n \n \n StopF50Plu\n \n \n \n \n \n \n StopF<1yr\n \n \n \n \n \n \n StopM1-4\n \n \n \n \n \n \n StopM10-14\n \n \n \n \n \n \n StopM15-19\n \n \n \n \n \n \n StopM20-24\n \n \n \n \n \n \n StopM25-29\n \n \n \n \n \n \n StopM30-34\n \n \n \n \n \n \n StopM35-39\n \n \n \n \n \n \n StopM40-44\n \n \n \n \n \n \n StopM45-49\n \n \n \n \n \n \n StopM5-9\n \n \n \n \n \n \n StopM50Plu\n \n \n \n \n \n \n StopM<1yr\n \n \n \n \n \n \n TOutF1-4\n \n \n \n \n \n \n \n \n \n TOutF10-14\n \n \n \n \n \n \n TOutF15-19\n \n \n \n \n \n \n TOutF20-24\n \n \n \n \n \n \n TOutF25-29\n \n \n \n \n \n \n TOutF30-34\n \n \n \n \n \n \n TOutF35-39\n \n \n \n \n \n \n TOutF40-44\n \n \n \n \n \n \n TOutF45-49\n \n \n \n \n \n \n TOutF5-9\n \n \n \n \n \n \n TOutF50Plu\n \n \n \n \n \n \n TOutF<1yr\n \n \n \n \n \n \n TOutM1-4\n \n \n \n \n \n \n TOutM10-14\n \n \n \n \n \n \n TOutM15-19\n \n \n \n \n \n \n TOutM20-24\n \n \n \n \n \n \n TOutM25-29\n \n \n \n \n \n \n TOutM30-34\n \n \n \n \n \n \n TOutM35-39\n \n \n \n \n \n \n TOutM40-44\n \n \n \n \n \n \n TOutM45-49\n \n \n \n \n \n \n TOutM5-9\n \n \n \n \n \n \n TOutM50PLu\n \n \n \n \n \n \n TOutM<1yr\n \n \n \n \n \n \n','2021-09-21 10:52:57',4,'2022-09-23 08:18:33',4,0,NULL,NULL,NULL,'81bde35e-8217-4ef4-988a-f578a52fd5d9'),(1217,'PITC_New_Positive_OPD','HTS Report - OPD location - PITC New Pos ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive_OPD\n HTS Report - OPD location - PITC New Pos \n \n 2021-09-23 11:38:55 UTC\n \n 2023-03-29 21:46: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 1217\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (2191,2190,2192,2139,4791,2143) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 13:38:55',4,'2023-03-29 23:46:24',4,0,NULL,NULL,NULL,'c9db805d-4bea-4f9a-a3ac-0325d0a27fa9'),(1218,'PITC_New_Negative_OPD','HTS Report - OPD location - PITC New Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative_OPD\n HTS Report - OPD location - PITC New Negative\n \n 2021-09-23 13:11:08 UTC\n \n 2023-03-29 21:41: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 1218\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (2191,2190,2192,2139,4791,2143) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:11:08',4,'2023-03-29 23:41:58',4,0,NULL,NULL,NULL,'e6471d7a-2acd-4bb6-9124-d757bc31a72b'),(1219,'PITC_Repeat_Positive_OPD','HTS Report - OPD location - PITC Repeat Pos','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive_OPD\n HTS Report - OPD location - PITC Repeat Pos\n \n 2021-09-23 13:13:09 UTC\n \n 2023-03-29 22:10: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 1219\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (2191,2190,2192,2139,4791,2143) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:13:09',4,'2023-03-30 00:10:02',4,0,NULL,NULL,NULL,'4b40c86a-2709-41dd-be33-d3efc05e2f66'),(1220,'PITC_Repeat_Negative_OPD',' HTS Report - OPD location - PITC Repeat Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative_OPD\n HTS Report - OPD location - PITC Repeat Negative\n \n 2021-09-23 13:20:34 UTC\n \n 2023-03-29 22:02: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 1220\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (2191,2190,2192,2139,4791,2143) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:20:34',4,'2023-03-30 00:02:24',4,0,NULL,NULL,NULL,'99ec373f-d9b7-4eb0-99e4-a245f3b7018d'),(1221,'PITC_New_Positive_Adolescent','HTS Report - Adolescent location - PITC New Pos','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive_Adolescent\n HTS Report - Adolescent location - PITC New Pos\n \n 2021-09-23 13:28:38 UTC\n \n 2023-03-29 21: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 1221\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4236 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:28:38',4,'2023-03-29 23:44:16',4,0,NULL,NULL,NULL,'ca12e57f-dbac-4bef-b6d3-43fa18145d53'),(1222,'PITC_New_Negative_Adolescent','HTS Report - Adolescent location - PITC New Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative_Adolescent\n HTS Report - Adolescent location - PITC New Negative\n \n 2021-09-23 13:32:28 UTC\n \n 2023-03-29 21:38: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 1222\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4236 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:32:28',4,'2023-03-29 23:38:24',4,0,NULL,NULL,NULL,'39bf8113-eca7-440e-b67c-baabc1c1400d'),(1223,'PITC_Repeat_Positive_Adolescent','HTS Report - Adolescent location - PITC Repeat Pos','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive_Adolescent\n HTS Report - Adolescent location - PITC Repeat Pos\n \n 2021-09-23 13:35:10 UTC\n \n 2023-03-29 22:07: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 1223\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4236 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:35:10',4,'2023-03-30 00:07:20',4,0,NULL,NULL,NULL,'117426a7-ca44-4b9b-b4c4-72f565c9b534'),(1224,'PITC_Repeat_Negative_Adolescent',' HTS Report - Adolescent location - PITC Repeat Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative_Adolescent\n HTS Report - Adolescent location - PITC Repeat Negative\n \n 2021-09-23 13:39:06 UTC\n \n 2023-03-29 21: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 1224\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4236 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:39:06',4,'2023-03-29 23:58:42',4,0,NULL,NULL,NULL,'eb4559df-958e-40ff-a863-abdcfcf257e8'),(1225,'PITC_New_Positive_ART','HTS Report - ART location - PITC New Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive_ART\n HTS Report - ART location - PITC New Positive\n \n 2021-09-23 13:46:15 UTC\n \n 2023-03-29 21:44: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 1225\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4234,3632,4816) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:46:15',4,'2023-03-29 23:44:45',4,0,NULL,NULL,NULL,'1590fd93-0b9e-4e42-93b7-98ce50da42a9'),(1226,'PITC_New_Negative_ART','HTS Report - ART location - PITC New Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative_ART\n HTS Report - ART location - PITC New Negative\n \n 2021-09-23 13:47:57 UTC\n \n 2023-03-29 21: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 1226\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4234,3632,4816) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:47:57',4,'2023-03-29 23:39:04',4,0,NULL,NULL,NULL,'d7b22cfb-e38a-4764-8e7c-c1950dee7bb1'),(1227,'PITC_Repeat_Positive_ART','HTS Report - ART location - PITC Repeat Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive_ART\n HTS Report - ART location - PITC Repeat Positive\n \n 2021-09-23 13:49:18 UTC\n \n 2023-03-29 22:08: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 1227\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4234,3632,4816) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:49:18',4,'2023-03-30 00:08:03',4,0,NULL,NULL,NULL,'037fb6a1-3ad9-421d-851b-29b857c36013'),(1228,'PITC_Repeat_Negative_ART','HTS Report - ART location - PITC Repeat Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative_ART\n HTS Report - ART location - PITC Repeat Negative\n \n 2021-09-23 13:50:31 UTC\n \n 2023-03-29 21:59: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 1228\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4234,3632,4816) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:50:31',4,'2023-03-29 23:59:13',4,0,NULL,NULL,NULL,'e80c4654-6566-43f8-a397-2ba993465ec0'),(1229,'PITC_New_Positive_Index','HTS Report - Index location - PITC New_Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive_Index\n HTS Report - Index location - PITC New_Positive\n \n 2021-09-23 14:10:52 UTC\n \n 2023-03-29 21:45: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 1229\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4792 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:10:52',4,'2023-03-29 23:45:18',4,0,NULL,NULL,NULL,'d6e893c7-5866-4f27-897d-c4547f2913b8'),(1230,'PITC_New_Negative_Index','HTS Report - Index location - PITC New_Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative_Index\n HTS Report - Index location - PITC New_Negative\n \n 2021-09-23 14:12:40 UTC\n \n 2023-03-29 21: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 1230\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4792 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:12:40',4,'2023-03-29 23:39:57',4,0,NULL,NULL,NULL,'ffc2c83d-60de-4432-9b5d-4b7107ea9961'),(1231,'PITC_Repeat_Positive_Index','HTS Report - Index location - PITC Repeat_Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive_Index\n HTS Report - Index location - PITC Repeat_Positive\n \n 2021-09-23 14:15:09 UTC\n \n 2023-03-29 22:08: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 1231\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4792 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:15:09',4,'2023-03-30 00:08:44',4,0,NULL,NULL,NULL,'d36cc9c3-352f-44cf-b949-3f19a426c39b'),(1232,'PITC_Repeat_Negative_Index',' HTS Report - Index location - PITC Repeat Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative_Index\n HTS Report - Index location - PITC Repeat Negative\n \n 2021-09-23 14:16:30 UTC\n \n 2023-03-29 21:59: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 1232\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4792 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:16:30',4,'2023-03-29 23:59:43',4,0,NULL,NULL,NULL,'2c72c8ff-e656-4dea-9f99-2ffe5885f78b'),(1233,'PITC_New_Positive_MCH','HTS Report - MCH location - PITC New Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive_MCH\n HTS Report - MCH location - PITC New Positive\n \n 2021-09-23 14:21:38 UTC\n \n 2023-03-29 21:45: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 1233\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4233,4790,4789,4788,4963) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:21:38',4,'2023-03-29 23:45:55',4,0,NULL,NULL,NULL,'42157f3d-e92a-4dd5-98ea-a0dff211087e'),(1234,'PITC_New_Negative_MCH','HTS Report - MCH location - PITC New Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative_MCH\n HTS Report - MCH location - PITC New Negative\n \n 2021-09-23 14:23:35 UTC\n \n 2023-03-29 21:40: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 1234\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4233,4790,4789,4788,4963) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:23:35',4,'2023-03-29 23:40:48',4,0,NULL,NULL,NULL,'d7573e09-749d-43ff-a390-fbf74e7209b6'),(1235,'PITC_Repeat_Positive_MCH','HTS Report - MCH location - PITC Repeat Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive_MCH\n HTS Report - MCH location - PITC Repeat Positive\n \n 2021-09-23 14:25:03 UTC\n \n 2023-03-29 22:09: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 1235\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4233,4790,4789,4788,4963) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:25:03',4,'2023-03-30 00:09:22',4,0,NULL,NULL,NULL,'c0b8921b-abf4-43af-b7f7-c9b0aeceb791'),(1236,'PITC_Repeat_Negative_MCH',' HTS Report - MCH location - PITC Repeat Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative_MCH\n HTS Report - MCH location - PITC Repeat Negative\n \n 2021-09-23 14:26:44 UTC\n \n 2023-03-29 22:00: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 1236\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4233,4790,4789,4788,4963) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:26:44',4,'2023-03-30 00:00:18',4,0,NULL,NULL,NULL,'11dc73c3-a8cb-4f9a-9e8b-e5362bba3785'),(1237,'PITC_New_Positive_Outreach','HTS Report - Outreach location - PITC New Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive_Outreach\n HTS Report - Outreach location - PITC New Positive\n \n 2021-09-23 14:31:30 UTC\n \n 2023-03-29 21:47: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 1237\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4796 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:31:30',4,'2023-03-29 23:47:34',4,0,NULL,NULL,NULL,'dbe49be8-2938-4430-85c6-74e3a0e8828d'),(1238,'PITC_New_Negative_Outreach','HTS Report - Outreach location - PITC New Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative_Outreach\n HTS Report - Outreach location - PITC New Negative\n \n 2021-09-23 14:33:43 UTC\n \n 2023-03-29 21:42: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 1238\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4796 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:33:43',4,'2023-03-29 23:42:31',4,0,NULL,NULL,NULL,'d34a7009-d9ca-4bab-baed-7a50cd4e5683'),(1239,'PITC_Repeat_Positive_Outreach',' HTS Report - Outreach location - PITC Repeat Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive_Outreach\n HTS Report - Outreach location - PITC Repeat Positive\n \n 2021-09-23 14:35:30 UTC\n \n 2023-03-29 22:10: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 1239\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4796 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:35:30',4,'2023-03-30 00:10:38',4,0,NULL,NULL,NULL,'79da84b1-174a-4c1a-b472-3c4ef965962f'),(1240,'PITC_Repeat_Negative_Outreach','HTS Report - Outreach location - PITC Repeat Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative_Outreach\n HTS Report - Outreach location - PITC Repeat Negative\n \n 2021-09-23 14:37:27 UTC\n \n 2023-03-29 22: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 1240\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4796 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:37:27',4,'2023-03-30 00:04:57',4,0,NULL,NULL,NULL,'5dceb80b-1b6a-45e6-9670-b209e3960b3b'),(1241,'PITC_New_Positive_SelfTest','HTS Report - Self Test - PITC New Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive_SelfTest\n HTS Report - Self Test - PITC New Positive\n \n 2021-09-23 14:42:18 UTC\n \n 2023-07-27 13:24: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 1241\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1738 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 -- HIV Positive \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n -- AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n Inner Join ( \n select encounter_id,CAST(date_created as Date) as current_conc \n from obs \n where concept_id = 4845 and value_coded = 4847 \n ) as rapids \n on o.encounter_id = rapids.encounter_id \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n \n )as testingform \n on o.person_id = testingform.person_id \n AND testingform.current_conc=rapids.current_conc \n inner join \n ( \n select os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4237 \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 AND patient.voided = 0 AND os.voided = 0 \n \n )as mode \n ON o.person_id = mode.person_id \n AND pitc.encounter = mode.encounter \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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n ) \n \n \n\n','2021-09-23 16:42:18',4,'2023-07-27 15:24:17',4,0,NULL,NULL,NULL,'a649af2e-c356-4c21-aae4-8ecf5325699e'),(1242,'PITC_New_Negative_SelfTest','HTS Report - Self Test - PITC New Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative_SelfTest\n HTS Report - Self Test - PITC New Negative\n \n 2021-09-23 14:45:04 UTC\n \n 2023-03-29 21:43: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 1242\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4237 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:45:04',4,'2023-03-29 23:43:06',4,0,NULL,NULL,NULL,'bfc795aa-cf34-4129-8765-08d8c5a6c265'),(1243,'PITC_Repeat_Positive_SelfTest','HTS Report - Self Test - PITC Repeat Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive_SelfTest\n HTS Report - Self Test - PITC Repeat Positive\n \n 2021-09-23 14:46:15 UTC\n \n 2023-03-29 22:11: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 1243\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4237 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:46:15',4,'2023-03-30 00:11:20',4,0,NULL,NULL,NULL,'1aea70b8-30cf-4ac8-b6b4-296293581073'),(1244,'PITC_Repeat_Negative_SelfTest',' HTS Report - Self Test - PITC Repeat Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative_SelfTest\n HTS Report - Self Test - PITC Repeat Negative\n \n 2021-09-23 14:50:02 UTC\n \n 2023-03-29 22:05: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 1244\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4237 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:50:02',4,'2023-03-30 00:05:37',4,0,NULL,NULL,NULL,'fa5d4491-570f-45e0-8e99-74849dffdd1c'),(1245,'PITC_New_Negative_VMMC','HTS Report - VMMC location - PITC New Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative_VMMC\n HTS Report - VMMC location - PITC New Negative\n \n 2021-09-23 15:14:55 UTC\n \n 2023-03-29 21:43: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 1245\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:14:55',4,'2023-03-29 23:43:38',4,0,NULL,NULL,NULL,'fe5844f9-5ccc-4ae2-ba58-524a6e4e9443'),(1246,'PITC_New_Positive_VMMC','HTS Report - VMMC location - PITC New Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive_VMMC\n HTS Report - VMMC location - PITC New Positive\n \n 2021-09-23 15:17:54 UTC\n \n 2023-03-29 21: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 1246\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:17:54',4,'2023-03-29 23:54:57',4,0,NULL,NULL,NULL,'f48462e3-b31a-4be6-8ce8-e41c3fdb8db3'),(1247,'PITC_Repeat_Negative_VMMC','HTS Report - VMMC location - PITC Repeat Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative_VMMC\n HTS Report - VMMC location - PITC Repeat Negative\n \n 2021-09-23 15:19:46 UTC\n \n 2023-03-29 22:06: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 1247\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:19:46',4,'2023-03-30 00:06:14',4,0,NULL,NULL,NULL,'10ee5adc-6d52-4b9a-9ba5-0892bb6277af'),(1248,'PITC_Repeat_Positive_VMMC',' HTS Report - VMMC location - PITC Repeat Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive_VMMC\n HTS Report - VMMC location - PITC Repeat Positive\n \n 2021-09-23 15:21:08 UTC\n \n 2023-03-29 22:11: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 1248\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:21:08',4,'2023-03-30 00:11:57',4,0,NULL,NULL,NULL,'e1bda5c3-3db3-487d-b7e5-48a817610de0'),(1249,'CITC_New_Negative_Adolescent','CITC_New_Negative_Adolescent','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative_Adolescent\n CITC_New_Negative_Adolescent\n \n 2021-09-23 15:37:47 UTC\n \n 2023-03-29 21:21: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 1249\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4236 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:37:47',4,'2023-03-29 23:21:00',4,0,NULL,NULL,NULL,'85f6e71c-dc8e-4387-b7d7-043e68866f3c'),(1250,'CITC_New_Negative_ART','CITC_New_Negative_ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative_ART\n CITC_New_Negative_ART\n \n 2021-09-23 15:39:50 UTC\n \n 2023-03-29 21:21: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 1250\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4234,3632,4816) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:39:50',4,'2023-03-29 23:21:33',4,0,NULL,NULL,NULL,'367af408-5c3c-4647-8726-a83e52c4ff47'),(1251,'CITC_New_Negative_Index','CITC_New_Negative_Index','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative_Index\n CITC_New_Negative_Index\n \n 2021-09-23 15:41:09 UTC\n \n 2023-03-29 21:22: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 1251\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4792 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:41:09',4,'2023-03-29 23:22:11',4,0,NULL,NULL,NULL,'fbd7dcc2-a114-458f-b17b-93ed30fee5bb'),(1252,'CITC_New_Negative_MCH','CITC_New_Negative_MCH','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative_MCH\n CITC_New_Negative_MCH\n \n 2021-09-23 15:42:38 UTC\n \n 2023-03-29 21: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 1252\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4233,4790,4789,4788,4963) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:42:38',4,'2023-03-29 23:22:43',4,0,NULL,NULL,NULL,'bee2be9a-3388-4e55-9f80-8247bda3b761'),(1253,'CITC_New_Negative_OPD','CITC_New_Negative_OPD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative_OPD\n CITC_New_Negative_OPD\n \n 2021-09-23 15:43:46 UTC\n \n 2023-03-29 21: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 1253\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (2191,2190,2192,2139,4791,2143) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:43:46',4,'2023-03-29 23:23:09',4,0,NULL,NULL,NULL,'20ddc359-4a4b-482e-bf81-822d607c9588'),(1254,'CITC_New_Negative_Outreach','CITC_New_Negative_Outreach','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative_Outreach\n CITC_New_Negative_Outreach\n \n 2021-09-23 15:44:49 UTC\n \n 2023-03-29 21:23: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 1254\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4796 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:44:49',4,'2023-03-29 23:23:40',4,0,NULL,NULL,NULL,'372a9429-574b-4c07-974a-a94004eb0494'),(1255,'CITC_New_Negative_SelfTest','CITC_New_Negative_SelfTest','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative_SelfTest\n CITC_New_Negative_SelfTest\n \n 2021-09-23 15:45:51 UTC\n \n 2023-03-29 21: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 1255\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4237 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:45:51',4,'2023-03-29 23:24:14',4,0,NULL,NULL,NULL,'e37ecdc9-6f00-4ec4-b449-ad6202184cf3'),(1256,'CITC_New_Negative_VMMC','CITC_New_Negative_VMMC','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative_VMMC\n CITC_New_Negative_VMMC\n \n 2021-09-23 15:47:06 UTC\n \n 2023-03-29 21: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 1256\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:47:06',4,'2023-03-29 23:24:44',4,0,NULL,NULL,NULL,'acace045-4faa-48c6-8506-0fd76448742c'),(1257,'CITC_New_Positive_Adolescent','CITC_New_Positive_Adolescent','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive_Adolescent\n CITC_New_Positive_Adolescent\n \n 2021-09-23 15:48:57 UTC\n \n 2023-03-29 21:25: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 1257\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4236 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:48:57',4,'2023-03-29 23:25:43',4,0,NULL,NULL,NULL,'0b88b543-501f-404d-8b05-1faea17d8d8b'),(1258,'CITC_New_Positive_ART','CITC_New_Positive_ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive_ART\n CITC_New_Positive_ART\n \n 2021-09-23 15:50:00 UTC\n \n 2023-03-29 21:26: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 1258\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4234,3632,4816) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:50:00',4,'2023-03-29 23:26:13',4,0,NULL,NULL,NULL,'64146038-ebce-479a-aed9-a22a50d3be2c'),(1259,'CITC_New_Positive_Index','CITC_New_Positive_Index','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive_Index\n CITC_New_Positive_Index\n \n 2021-09-23 15:50:59 UTC\n \n 2023-03-29 21:27: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 1259\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4792 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:50:59',4,'2023-03-29 23:27:03',4,0,NULL,NULL,NULL,'1bb82f9f-f0ce-4b5a-9f30-595b8a8874e4'),(1260,'CITC_New_Positive_MCH','CITC_New_Positive_MCH','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive_MCH\n CITC_New_Positive_MCH\n \n 2021-09-23 15:52:21 UTC\n \n 2023-03-29 21:28: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 1260\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4233,4790,4789,4788,4963) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:52:21',4,'2023-03-29 23:28:20',4,0,NULL,NULL,NULL,'cc978652-e959-4011-8ec9-ede5f7eadffa'),(1261,'CITC_New_Positive_OPD','CITC_New_Positive_OPD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive_OPD\n CITC_New_Positive_OPD\n \n 2021-09-23 15:53:34 UTC\n \n 2023-03-29 21:28: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 1261\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (2191,2190,2192,2139,4791,2143) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:53:34',4,'2023-03-29 23:28:58',4,0,NULL,NULL,NULL,'3c5a067c-6576-450a-a2ff-0854a65161e3'),(1262,'CITC_New_Positive_Outreach','CITC_New_Positive_Outreach','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive_Outreach\n CITC_New_Positive_Outreach\n \n 2021-09-23 15:54:37 UTC\n \n 2023-03-29 21:29: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 1262\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4796 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:54:37',4,'2023-03-29 23:29:31',4,0,NULL,NULL,NULL,'87777c2f-4e15-4938-adf5-1ad72278602a'),(1263,'CITC_New_Positive_SelfTest','CITC_New_Positive_SelfTest','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive_SelfTest\n CITC_New_Positive_SelfTest\n \n 2021-09-23 15:55:47 UTC\n \n 2023-03-29 21:33: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 1263\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4237 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:55:47',4,'2023-03-29 23:33:24',4,0,NULL,NULL,NULL,'6ebae90a-62f2-493c-9150-2a2d1a47d356'),(1264,'CITC_New_Positive_VMMC','CITC_New_Positive_VMMC','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive_VMMC\n CITC_New_Positive_VMMC\n \n 2021-09-23 15:56:53 UTC\n \n 2023-03-29 21:33: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 1264\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:56:53',4,'2023-03-29 23:33:58',4,0,NULL,NULL,NULL,'4814aba2-99d9-4de9-9c9c-167240cfbb51'),(1265,'CITC_Repeat_Negative_Adolescent','CITC_Repeat_Negative_Adolescent','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative_Adolescent\n CITC_Repeat_Negative_Adolescent\n \n 2021-09-23 15:58:44 UTC\n \n 2023-03-29 21: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 1265\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4236 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:58:44',4,'2023-03-29 23:07:15',4,0,NULL,NULL,NULL,'565e2079-5073-435a-bd06-10cdd8bfeb1a'),(1266,'CITC_Repeat_Negative_ART','CITC_Repeat_Negative_ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative_ART\n CITC_Repeat_Negative_ART\n \n 2021-09-23 15:59:50 UTC\n \n 2023-03-29 21:07:59 UTC\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 endDate\n \n java.util.Date\n true\n \n \n 1266\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4234,3632,4816) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:59:50',4,'2023-03-29 23:07:59',4,0,NULL,NULL,NULL,'2b13b640-dd8b-4c45-8804-11a7273d0bec'),(1267,'CITC_Repeat_Negative_Index','CITC_Repeat_Negative_Index','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative_Index\n CITC_Repeat_Negative_Index\n \n 2021-09-23 16:01:18 UTC\n \n 2023-03-29 21:09: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 1267\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- REPEAT TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4792 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:01:18',4,'2023-03-29 23:09:28',4,0,NULL,NULL,NULL,'4b278eff-3949-4e7f-b882-beb195486860'),(1268,'CITC_Repeat_Negative_MCH','CITC_Repeat_Negative_MCH','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative_MCH\n CITC_Repeat_Negative_MCH\n \n 2021-09-23 16:02:17 UTC\n \n 2023-03-29 21: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 1268\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4233,4790,4789,4788,4963) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:02:17',4,'2023-03-29 23:10:08',4,0,NULL,NULL,NULL,'1a8d4028-ce12-478f-b787-0b08fdf93d09'),(1269,'CITC_Repeat_Negative_OPD','CITC_Repeat_Negative_OPD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative_OPD\n CITC_Repeat_Negative_OPD\n \n 2021-09-23 16:03:27 UTC\n \n 2023-03-29 21:10: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 1269\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (2191,2190,2192,2139,4791,2143) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:03:27',4,'2023-03-29 23:10:42',4,0,NULL,NULL,NULL,'bc578ea3-8d52-40e1-93bf-91f20b569cd1'),(1271,'CITC_Repeat_Negative_Outreach','CITC_Repeat_Negative_Outreach','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative_Outreach\n CITC_Repeat_Negative_Outreach\n \n 2021-09-23 16:05:51 UTC\n \n 2023-03-29 21:11: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 1271\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4796 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:05:51',4,'2023-03-29 23:11:26',4,0,NULL,NULL,NULL,'c1365a92-6aa6-497b-b492-dc535c2a1081'),(1272,'CITC_Repeat_Negative_SelfTest','CITC_Repeat_Negative_SelfTest','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative_SelfTest\n CITC_Repeat_Negative_SelfTest\n \n 2021-09-23 16:07:53 UTC\n \n 2023-03-29 21:12:52 UTC\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 endDate\n \n java.util.Date\n true\n \n \n 1272\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4237 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:07:53',4,'2023-03-29 23:12:52',4,0,NULL,NULL,NULL,'90b6281c-7a7c-467b-9f9b-fb4c6265ce3a'),(1273,'CITC_Repeat_Negative_VMMC','CITC_Repeat_Negative_VMMC','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative_VMMC\n CITC_Repeat_Negative_VMMC\n \n 2021-09-23 16:09:16 UTC\n \n 2023-03-29 21:13: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 1273\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:09:16',4,'2023-03-29 23:13:30',4,0,NULL,NULL,NULL,'d2cd3398-b123-4da9-8765-ded2bce6c333'),(1274,'CITC_Repeat_Positive_Adolescent','CITC_Repeat_Positive_Adolescent','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive_Adolescent\n CITC_Repeat_Positive_Adolescent\n \n 2021-09-23 16:12:39 UTC\n \n 2023-03-29 21:14: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 1274\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4236 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:12:39',4,'2023-03-29 23:14:44',4,0,NULL,NULL,NULL,'78a793c7-8fb1-482c-a9fd-9ad9bb68df2e'),(1275,'CITC_Repeat_Positive_ART','CITC_Repeat_Positive_ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive_ART\n CITC_Repeat_Positive_ART\n \n 2021-09-23 16:14:08 UTC\n \n 2023-03-29 21:15: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 1275\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4234,3632,4816) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:14:08',4,'2023-03-29 23:15:29',4,0,NULL,NULL,NULL,'c030603d-1fa2-4477-aef8-2214f335513a'),(1276,'CITC_Repeat_Positive_Index','CITC_Repeat_Positive_Index','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive_Index\n CITC_Repeat_Positive_Index\n \n 2021-09-23 16:15:05 UTC\n \n 2023-03-29 21:16: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 1276\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4792 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:15:05',4,'2023-03-29 23:16:06',4,0,NULL,NULL,NULL,'442b5cdb-bb91-421b-a902-b88675b591cc'),(1277,'CITC_Repeat_Positive_MCH','CITC_Repeat_Positive_MCH','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive_MCH\n CITC_Repeat_Positive_MCH\n \n 2021-09-23 16:15:57 UTC\n \n 2023-03-29 21:17: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 1277\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4233,4790,4789,4788,4963) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:15:57',4,'2023-03-29 23:17:06',4,0,NULL,NULL,NULL,'cdc95d8b-968e-42ae-bc6b-2efeec7afa7b'),(1278,'CITC_Repeat_Positive_Outreach','CITC_Repeat_Positive_Outreach','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive_Outreach\n CITC_Repeat_Positive_Outreach\n \n 2021-09-23 16:16:55 UTC\n \n 2023-03-29 21:18: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 1278\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4796 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:16:55',4,'2023-03-29 23:18:10',4,0,NULL,NULL,NULL,'64cc6744-8909-4965-889a-e0da7a0b3cac'),(1279,'CITC_Repeat_Positive_SelfTest','CITC_Repeat_Positive_SelfTest','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive_SelfTest\n CITC_Repeat_Positive_SelfTest\n \n 2021-09-23 16:17:57 UTC\n \n 2023-03-29 21:18: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 1279\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4237 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:17:57',4,'2023-03-29 23:18:44',4,0,NULL,NULL,NULL,'cf8860a8-6bc2-421d-a339-cfe9a7318a66'),(1280,'CITC_Repeat_Positive_VMMC','CITC_Repeat_Positive_VMMC','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive_VMMC\n CITC_Repeat_Positive_VMMC\n \n 2021-09-23 16:18:57 UTC\n \n 2023-03-29 21:19:25 UTC\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 endDate\n \n java.util.Date\n true\n \n \n 1280\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:18:57',4,'2023-03-29 23:19:25',4,0,NULL,NULL,NULL,'4507f03d-8c79-4090-994e-54780740d9f7'),(1281,'CITC_Repeat_Positive_OPD','CITC_Repeat_Positive_OPD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive_OPD\n CITC_Repeat_Positive_OPD\n \n 2021-09-23 16:20:49 UTC\n \n 2023-03-29 21:17: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 1281\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (2191,2190,2192,2139,4791,2143) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:20:49',4,'2023-03-29 23:17:40',4,0,NULL,NULL,NULL,'20044501-f5dc-463d-ab2a-a35acbc603e9'),(1282,'self_test_confirmed_positive','Self Test Confirmed Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n self_test_confirmed_positive\n Self Test Confirmed Positive\n \n 2021-09-23 16:51:41 UTC\n \n 2021-09-23 16:53: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 1282\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 \n(SELECT Id \nFROM ( \n(SELECT distinct Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'Self-test' AS 'HIV_Testing_Initiation' \n , HIV_Status \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 (select name from concept_name cn where cn.concept_id = 1738 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \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 -- HTS SELF TEST STRATEGY \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4845 and value_coded = 4822 \n AND patient.voided = 0 AND o.voided = 0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n -- HAS HIV POSITIVE RESULTS \n AND o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 4844 and os.value_coded = 1738 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND patient.voided = 0 AND o.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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age)as Pos_Self_Test \n \n \n left outer join \n ( \n select distinct os.person_id \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND patient.voided = 0 AND os.voided = 0 \n -- group by os.person_id \n )B \n ON B.person_id = Pos_Self_Test.Id) \n \n )\n','2021-09-23 18:51:41',4,'2021-09-23 18:53:41',4,0,NULL,NULL,NULL,'0d599d57-f118-4476-b5d6-43c4a3920345'),(1283,'PITC_New_Pos_OPD','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Pos_OPD\n \n \n 2021-09-23 17:10:50 UTC\n \n 2021-09-23 17:12: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 1283\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-23 19:10:50',4,'2021-09-23 19:12:21',4,0,NULL,NULL,NULL,'e135248a-7300-4a02-a819-277e8fdebe14'),(1285,'PITC_HTS_OPD','HTS Report for OPD location','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_OPD\n HTS Report for OPD location\n \n 2021-09-23 17:13:34 UTC\n \n 2021-09-28 13:21: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 1285\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','2021-09-23 19:13:34',4,'2021-09-28 15:21:49',4,0,NULL,NULL,NULL,'e36bd994-3d64-4020-a13a-e3bf5734263b'),(1286,'HTS_OPD Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS_OPD Data Set\n \n 2021-09-23 17:13: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 \n \n','2021-09-23 19:13:49',4,NULL,NULL,0,NULL,NULL,NULL,'d294a5d3-dee6-4b78-b48e-1221d73a2c30'),(1287,'HTS_OPD Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS_OPD Data Set\n \n 2021-09-23 17:13:51 UTC\n \n 2021-09-28 16:35: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 1287\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1yr\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-09-23 19:13:51',4,'2021-09-28 18:35:20',4,0,NULL,NULL,NULL,'81a5c7be-091e-47b2-8379-3dac06f96214'),(1288,'PITC_New_Neg_OPD','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Neg_OPD\n \n \n 2021-09-23 17:25:24 UTC\n \n 2021-09-23 17:26: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 1288\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-23 19:25:24',4,'2021-09-23 19:26:18',4,0,NULL,NULL,NULL,'3aea6253-1697-4ac3-ab0a-c085d8f81762'),(1289,'PITC_Repeat_Pos_OPD','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Pos_OPD\n \n \n 2021-09-23 17:28:09 UTC\n \n 2021-09-23 17:30:12 UTC\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 endDate\n \n java.util.Date\n true\n \n \n 1289\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-23 19:28:09',4,'2021-09-23 19:30:12',4,0,NULL,NULL,NULL,'f38aecb9-6b9f-48b8-91ad-3d6a428630df'),(1290,'PITC_Repeat_Neg_OPD','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Neg_OPD\n \n \n 2021-09-23 17:31:18 UTC\n \n 2021-09-23 17: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 1290\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-23 19:31:18',4,'2021-09-23 19:32:04',4,0,NULL,NULL,NULL,'d7b620d3-c912-4fa9-b9f7-9b9a22443d3a'),(1291,'CITC_New_Pos_OPD','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Pos_OPD\n \n \n 2021-09-23 17:32:43 UTC\n \n 2021-09-23 17:33:30 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n 1291\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-23 19:32:43',4,'2021-09-23 19:33:30',4,0,NULL,NULL,NULL,'a7b1118f-8ce9-4af0-8611-c0d94fe28277'),(1292,'CITC_New_Neg_OPD','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Neg_OPD\n \n \n 2021-09-23 17:33:56 UTC\n \n 2021-09-23 17:34: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 1292\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-23 19:33:56',4,'2021-09-23 19:34:34',4,0,NULL,NULL,NULL,'bea053b1-27d1-4cee-b191-f41df2b51291'),(1293,'CITC_Repeat_Pos_OPD','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Pos_OPD\n \n \n 2021-09-23 17:35:00 UTC\n \n 2021-09-23 17:36: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 1293\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-23 19:35:00',4,'2021-09-23 19:36:28',4,0,NULL,NULL,NULL,'08a34077-6dd2-4b18-b2cf-a998b7fa6c3b'),(1294,'CITC_Repeat_Neg_OPD','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Neg_OPD\n \n \n 2021-09-23 17:36:58 UTC\n \n 2021-09-23 17:37: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 1294\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-23 19:36:58',4,'2021-09-23 19:37:45',4,0,NULL,NULL,NULL,'496ad2d1-f6f1-423e-8584-4304bb3286df'),(1295,'CITC_HTS_OPD','CITC_HTS Report for OPD location','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_OPD\n CITC_HTS Report for OPD location\n \n 2021-09-28 13:51:08 UTC\n \n 2021-09-29 13:02: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 1295\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','2021-09-28 15:51:08',4,'2021-09-29 15:02:03',4,0,NULL,NULL,NULL,'77fca612-86fe-4cbf-98b7-9556c57f11e4'),(1296,'OPD_HTS_CITC Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n OPD_HTS_CITC Data Set\n \n 2021-09-28 13:51:16 UTC\n \n 2021-09-28 14:58: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 1296\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-09-28 15:51:16',4,'2021-09-28 16:58:35',4,0,NULL,NULL,NULL,'16c7f7fe-f944-4c3c-938d-deebb122a333'),(1297,'PITC_New_Neg_Outreach','PITC_New_Neg_Outreach','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Neg_Outreach\n PITC_New_Neg_Outreach\n \n 2021-09-30 13:45:14 UTC\n \n 2021-09-30 13:46: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 1297\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-30 15:45:14',4,'2021-09-30 15:46:33',4,0,NULL,NULL,NULL,'39057cef-8337-4ff3-a8a2-91fa6e5c548d'),(1298,'PITC_New_Pos_Outreach','PITC_New_Pos_Outreach','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Pos_Outreach\n PITC_New_Pos_Outreach\n \n 2021-09-30 13:47:37 UTC\n \n 2021-09-30 13:48: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 1298\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-30 15:47:37',4,'2021-09-30 15:48:31',4,0,NULL,NULL,NULL,'0a9cfa8f-1e23-447d-9392-0fca529a0953'),(1299,'PITC_Repeat_Neg_Outreach','PITC_Repeat_Neg_Outreach','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Neg_Outreach\n PITC_Repeat_Neg_Outreach\n \n 2021-09-30 13:48:59 UTC\n \n 2021-09-30 13:50: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 1299\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-30 15:48:59',4,'2021-09-30 15:50:39',4,0,NULL,NULL,NULL,'c8aae0d9-3f3d-4ce1-b4c7-a143047bb1f9'),(1300,'PITC_Repeat_Pos_Outreach','PITC_Repeat_Pos_Outreach','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Pos_Outreach\n PITC_Repeat_Pos_Outreach\n \n 2021-09-30 13:49:32 UTC\n \n 2021-09-30 13:51: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 1300\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-30 15:49:32',4,'2021-09-30 15:51:02',4,0,NULL,NULL,NULL,'0baa5b16-2c08-43b5-b8b0-f79631c81a65'),(1301,'PITC_HTS_Outreach','HTS Report for Outreach location','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_Outreach\n HTS Report for Outreach location\n \n 2021-09-30 13:52:55 UTC\n \n 2021-09-30 14:51: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 1301\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','2021-09-30 15:52:55',4,'2021-09-30 16:51:37',4,0,NULL,NULL,NULL,'82447585-c743-4981-9ae3-cb2ca701d480'); -INSERT INTO `serialized_object` VALUES (1302,'PITC_HTS_Outreach Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_Outreach Data Set\n \n 2021-09-30 13:53:05 UTC\n \n 2021-09-30 14:40: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 1302\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-09-30 15:53:05',4,'2021-09-30 16:40:26',4,0,NULL,NULL,NULL,'617f0c89-e7d6-4e28-b9d0-77c22b59c8e8'),(1303,'CITC_New_Neg_Outreach','CITC_New_Neg_Outreach','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Neg_Outreach\n CITC_New_Neg_Outreach\n \n 2021-09-30 19:52:49 UTC\n \n 2021-09-30 19:59: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 1303\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-30 21:52:49',4,'2021-09-30 21:59:14',4,0,NULL,NULL,NULL,'d55affa6-233e-42b7-b781-2d35bcb11d20'),(1304,'CITC_New_Pos_Outreach','CITC_New_Pos_Outreach','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Pos_Outreach\n CITC_New_Pos_Outreach\n \n 2021-09-30 19:53:13 UTC\n \n 2021-09-30 20:04: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 1304\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-30 21:53:13',4,'2021-09-30 22:04:23',4,0,NULL,NULL,NULL,'70d48a98-c83c-4d92-83eb-ecbb22050996'),(1305,'CITC_Repeat_Neg_Outreach','CITC_Repeat_Neg_Outreach','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Neg_Outreach\n CITC_Repeat_Neg_Outreach\n \n 2021-09-30 19:54:25 UTC\n \n 2021-09-30 20:06: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 1305\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-30 21:54:25',4,'2021-09-30 22:06:45',4,0,NULL,NULL,NULL,'dcd9c782-fff7-4481-9f61-958f8484b9a0'),(1306,'CITC_Repeat_Pos_Outreach','CITC_Repeat_Pos_Outreach','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Pos_Outreach\n CITC_Repeat_Pos_Outreach\n \n 2021-09-30 19:55:31 UTC\n \n 2021-09-30 20:06: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 1306\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-30 21:55:31',4,'2021-09-30 22:06:31',4,0,NULL,NULL,NULL,'37c3dd42-9503-4957-a234-d18cdd62a67a'),(1307,'CITC_HTS_Outreach','CITC_HTS_Outreach','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_Outreach\n CITC_HTS_Outreach\n \n 2021-09-30 20:03:27 UTC\n \n 2021-09-30 20:04: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 1307\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','2021-09-30 22:03:27',4,'2021-09-30 22:04:04',4,0,NULL,NULL,NULL,'6e3130f4-4993-4e26-adce-598c242565e9'),(1308,'CITC_HTS_Outreach Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_Outreach Data Set\n \n 2021-09-30 20:04:04 UTC\n \n 2021-09-30 22:06: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 1308\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-09-30 22:04:04',4,'2021-10-01 00:06:25',4,0,NULL,NULL,NULL,'ac8c58c1-770c-4770-8418-4597c8b55c15'),(1309,' PITC_New_Neg_Adolescent',' PITC_New_Neg_Adolescent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Neg_Adolescent\n PITC_New_Neg_Adolescent\n \n 2021-10-05 20:43:32 UTC\n \n 2021-10-05 20: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 1309\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-05 22:43:32',4,'2021-10-05 22:48:56',4,0,NULL,NULL,NULL,'6aa142db-2786-4b21-beba-0ec77f22b523'),(1310,' PITC_New_Pos_Adolescent',' PITC_New_Pos_Adolescent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Pos_Adolescent\n PITC_New_Pos_Adolescent\n \n 2021-10-05 20:45:02 UTC\n \n 2021-10-05 20:49: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 1310\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-05 22:45:02',4,'2021-10-05 22:49:16',4,0,NULL,NULL,NULL,'8da0c564-e37c-447a-bb9c-81f65a635eae'),(1311,' PITC_Repeat_Neg_Adolescent',' PITC_Repeat_Neg_Adolescent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Neg_Adolescent\n PITC_Repeat_Neg_Adolescent\n \n 2021-10-05 20:46:27 UTC\n \n 2021-10-05 20:50: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 1311\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-05 22:46:27',4,'2021-10-05 22:50:02',4,0,NULL,NULL,NULL,'80d3e806-5077-42e0-9e5d-a89bd8579e73'),(1312,' PITC_Repeat_Pos_Adolescent',' PITC_Repeat_Pos_Adolescent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Pos_Adolescent\n PITC_Repeat_Pos_Adolescent\n \n 2021-10-05 20:47:22 UTC\n \n 2021-10-05 20:50: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 1312\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-05 22:47:22',4,'2021-10-05 22:50:21',4,0,NULL,NULL,NULL,'7ed0ead3-64c7-4529-9b3e-c82025462bb6'),(1313,'PITC_HTS_Adolescent','HTS Report for Adolescent location','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_Adolescent\n HTS Report for Adolescent location\n \n 2021-10-05 20:54:10 UTC\n \n 2021-10-05 20:54: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 1313\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','2021-10-05 22:54:10',4,'2021-10-05 22:54:35',4,0,NULL,NULL,NULL,'7f017fec-79d5-4ea6-87ba-be936e919d6b'),(1314,'PITC_HTS_Adolescent Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_Adolescent Data Set\n \n 2021-10-05 20:54:35 UTC\n \n 2021-10-06 06:00: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 1314\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-05 22:54:35',4,'2021-10-06 08:00:38',4,0,NULL,NULL,NULL,'3559e185-9b49-4159-a276-bee817744132'),(1315,'CITC_New_Neg_Adolescent','CITC_New_Neg_Adolescent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Neg_Adolescent\n CITC_New_Neg_Adolescent\n \n 2021-10-06 09:39:49 UTC\n \n 2021-10-06 09:44: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 1315\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 11:39:49',4,'2021-10-06 11:44:29',4,0,NULL,NULL,NULL,'eb91b86e-c2db-4d3b-8a67-7dc511379d4a'),(1316,'CITC_New_Pos_Adolescent','CITC_New_Pos_Adolescent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Pos_Adolescent\n CITC_New_Pos_Adolescent\n \n 2021-10-06 09:40:53 UTC\n \n 2021-10-06 09:44: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 1316\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 11:40:53',4,'2021-10-06 11:44:45',4,0,NULL,NULL,NULL,'53065d6f-4498-41e0-92f5-907e584e85fa'),(1317,'CITC_Repeat_Neg_Adolescent','CITC_Repeat_Neg_Adolescent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Neg_Adolescent\n CITC_Repeat_Neg_Adolescent\n \n 2021-10-06 09:41:27 UTC\n \n 2021-10-06 09: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 1317\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 11:41:27',4,'2021-10-06 11:45:02',4,0,NULL,NULL,NULL,'787ad098-ef27-4117-9acf-28781458e03e'),(1318,'CITC_Repeat_Pos_Adolescent','CITC_Repeat_Pos_Adolescent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Pos_Adolescent\n CITC_Repeat_Pos_Adolescent\n \n 2021-10-06 09:41:52 UTC\n \n 2021-10-06 09:45: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 1318\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 11:41:52',4,'2021-10-06 11:45:17',4,0,NULL,NULL,NULL,'67dbab08-8fee-479d-a0af-ff4ac7dc8648'),(1319,'CITC_HTS_Adolescent','CITC_HTS_Adolescent','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_Adolescent\n CITC_HTS_Adolescent\n \n 2021-10-06 09:46:57 UTC\n \n 2021-10-06 09:47: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 1319\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','2021-10-06 11:46:57',4,'2021-10-06 11:47:25',4,0,NULL,NULL,NULL,'6992581e-4161-4f22-b90a-36dc1965ccfd'),(1320,'CITC_HTS_Adolescent Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_Adolescent Data Set\n \n 2021-10-06 09:47:25 UTC\n \n 2021-10-06 15:27: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 1320\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-06 11:47:25',4,'2021-10-06 17:27:43',4,0,NULL,NULL,NULL,'4a64819c-e83a-4486-bc35-3b94e45e6285'),(1321,' PITC_New_Neg_MCH',' PITC_New_Neg_MCH','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Neg_MCH\n PITC_New_Neg_MCH\n \n 2021-10-06 15:32:10 UTC\n \n 2021-10-06 15:35: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 1321\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 17:32:10',4,'2021-10-06 17:35:35',4,0,NULL,NULL,NULL,'da4ee526-eb6c-475d-925c-ab56da241de3'),(1322,' PITC_New_Pos_MCH',' PITC_New_Pos_MCH','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Pos_MCH\n PITC_New_Pos_MCH\n \n 2021-10-06 15:32:39 UTC\n \n 2021-10-06 15:35: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 1322\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 17:32:39',4,'2021-10-06 17:35:50',4,0,NULL,NULL,NULL,'b3e9452d-7a33-4d06-ae8c-5e730923eb7b'),(1323,' PITC_Repeat_Neg_MCH',' PITC_Repeat_Neg_MCH','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Neg_MCH\n PITC_Repeat_Neg_MCH\n \n 2021-10-06 15:33:14 UTC\n \n 2021-10-06 15:36: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 1323\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 17:33:14',4,'2021-10-06 17:36:49',4,0,NULL,NULL,NULL,'168f838a-8ac0-43f1-a178-bb24cff130f1'),(1324,' PITC_Repeat_Pos_MCH',' PITC_Repeat_Pos_MCH','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Pos_MCH\n PITC_Repeat_Pos_MCH\n \n 2021-10-06 15:33:43 UTC\n \n 2021-10-06 15:37: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 1324\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 17:33:43',4,'2021-10-06 17:37:03',4,0,NULL,NULL,NULL,'49998468-941c-4817-b3e7-ada1ea8862cc'),(1325,'PITC_HTS_MCH','HTS Report for MCH location','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_MCH\n HTS Report for MCH location\n \n 2021-10-06 15:39:51 UTC\n \n 2021-10-07 04: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 1325\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','2021-10-06 17:39:51',4,'2021-10-07 06:34:03',4,0,NULL,NULL,NULL,'d946548e-a7f9-4115-bcd3-f78afdab092d'),(1326,'PITC_HTS_MCH Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_MCH Data Set\n \n 2021-10-06 15:40:13 UTC\n \n 2021-10-06 21:25: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 1326\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-06 17:40:13',4,'2021-10-06 23:25:14',4,0,NULL,NULL,NULL,'e7bbe762-47b2-4ca9-adcb-64e8b0cd50e1'),(1327,'CITC_New_Pos_MCH','CITC_New_Pos_MCH','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Pos_MCH\n CITC_New_Pos_MCH\n \n 2021-10-06 21:29:56 UTC\n \n 2021-10-06 21:33: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 1327\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 23:29:56',4,'2021-10-06 23:33:10',4,0,NULL,NULL,NULL,'ca78fdaa-e5f6-498e-9781-9cf1f8366220'),(1328,'CITC_New_Neg_MCH','CITC_New_Neg_MCH','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Neg_MCH\n CITC_New_Neg_MCH\n \n 2021-10-06 21:30:12 UTC\n \n 2021-10-06 21:32: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 1328\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 23:30:12',4,'2021-10-06 23:32:49',4,0,NULL,NULL,NULL,'32c4681d-fbde-4aa3-b10c-bf6393b39a4b'),(1329,'CITC_Repeat_Neg_MCH','CITC_Repeat_Neg_MCH','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Neg_MCH\n CITC_Repeat_Neg_MCH\n \n 2021-10-06 21:30:32 UTC\n \n 2021-10-06 21:33: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 1329\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 23:30:32',4,'2021-10-06 23:33:53',4,0,NULL,NULL,NULL,'51f2438c-b8a5-47c2-8703-c04885de774e'),(1330,'CITC_Repeat_Pos_MCH','CITC_Repeat_Pos_MCH','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Pos_MCH\n CITC_Repeat_Pos_MCH\n \n 2021-10-06 21:30:46 UTC\n \n 2021-10-06 21: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 1330\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 23:30:46',4,'2021-10-06 23:34:06',4,0,NULL,NULL,NULL,'50a98d1c-3cc7-43e9-824b-dde34f55e120'),(1331,'CITC_HTS_MCH','CITC_HTS_MCH','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_MCH\n CITC_HTS_MCH\n \n 2021-10-06 21:36:13 UTC\n \n 2021-10-06 21:36: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 1331\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','2021-10-06 23:36:13',4,'2021-10-06 23:36:35',4,0,NULL,NULL,NULL,'65873a4c-f706-4491-afc1-1a6ee9f18a35'),(1332,'CITC_HTS_MCH Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_MCH Data Set\n \n 2021-10-06 21:36:35 UTC\n \n 2021-10-06 23:12: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 1332\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-06 23:36:35',4,'2021-10-07 01:12:16',4,0,NULL,NULL,NULL,'545ac344-383c-40fb-b248-f42915e427f5'),(1333,'PITC_New_Neg_Index','PITC_New_Neg_Index','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Neg_Index\n PITC_New_Neg_Index\n \n 2021-10-07 04:25:39 UTC\n \n 2021-10-07 04:29: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 1333\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 06:25:39',4,'2021-10-07 06:29:23',4,0,NULL,NULL,NULL,'4c7fd830-a0c3-4e72-950c-05b972769d55'),(1334,'PITC_New_Pos_Index','PITC_New_Pos_Index','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Pos_Index\n PITC_New_Pos_Index\n \n 2021-10-07 04:25:56 UTC\n \n 2021-10-07 04:29: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 1334\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 06:25:56',4,'2021-10-07 06:29:46',4,0,NULL,NULL,NULL,'a4977c25-a493-47af-a8c9-7add78c9adf9'),(1335,'PITC_Repeat_Neg_Index','PITC_Repeat_Neg_Index','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Neg_Index\n PITC_Repeat_Neg_Index\n \n 2021-10-07 04:26:41 UTC\n \n 2021-10-07 04:30: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 1335\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 06:26:41',4,'2021-10-07 06:30:04',4,0,NULL,NULL,NULL,'e3e5f2be-eb19-4c33-8b0c-72d67e791ab4'),(1336,'PITC_Repeat_Pos_Index','PITC_Repeat_Pos_Index','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Pos_Index\n PITC_Repeat_Pos_Index\n \n 2021-10-07 04:26:54 UTC\n \n 2021-10-07 04:30: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 1336\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 06:26:54',4,'2021-10-07 06:30:41',4,0,NULL,NULL,NULL,'dbb343c4-6946-4a13-b6dc-e2a2e77dfaed'),(1337,'PITC_HTS_Index','HTS Report for Index Clients','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_Index\n HTS Report for Index Clients\n \n 2021-10-07 04:33:41 UTC\n \n 2021-10-07 04:34: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 1337\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','2021-10-07 06:33:41',4,'2021-10-07 06:34:05',4,0,NULL,NULL,NULL,'ce0ad8fd-bde8-4fce-be69-23e238f249bb'),(1338,'PITC_HTS_Index Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_Index Data Set\n \n 2021-10-07 04:34:04 UTC\n \n 2021-10-07 06: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 1338\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-07 06:34:04',4,'2021-10-07 08:43:10',4,0,NULL,NULL,NULL,'6425e4dd-681d-43a9-912b-3b0b6367a969'),(1339,'CITC_New_Neg_Index','CITC_New_Neg_Index','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Neg_Index\n CITC_New_Neg_Index\n \n 2021-10-07 07:25:59 UTC\n \n 2021-10-07 07:31: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 1339\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 09:25:59',4,'2021-10-07 09:31:52',4,0,NULL,NULL,NULL,'976b5e87-e40a-4e5f-822b-2b41ae0f7ecc'),(1340,'CITC_New_Pos_Index','CITC_New_Pos_Index','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Pos_Index\n CITC_New_Pos_Index\n \n 2021-10-07 07:26:54 UTC\n \n 2021-10-07 07:30: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 1340\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 09:26:54',4,'2021-10-07 09:30:52',4,0,NULL,NULL,NULL,'5286eeaa-dfe4-4d69-ba48-8931a03a1a8d'),(1341,'CITC_Repeat_Neg_Index','CITC_Repeat_Neg_Index','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Neg_Index\n CITC_Repeat_Neg_Index\n \n 2021-10-07 07:27:26 UTC\n \n 2021-10-07 07:31: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 1341\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 09:27:26',4,'2021-10-07 09:31:17',4,0,NULL,NULL,NULL,'ad69563a-424d-4772-8869-d366a9d92307'),(1342,'CITC_Repeat_Pos_Index','CITC_Repeat_Pos_Index','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Pos_Index\n CITC_Repeat_Pos_Index\n \n 2021-10-07 07:28:27 UTC\n \n 2021-10-07 07: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 1342\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 09:28:27',4,'2021-10-07 09:31:36',4,0,NULL,NULL,NULL,'e1cc0a62-96a8-4f4c-9d05-49e3ccd97fed'),(1343,'CITC_HTS_Index','CITC_HTS_Index','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_Index\n CITC_HTS_Index\n \n 2021-10-07 07:33:43 UTC\n \n 2021-10-07 07:34: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 1343\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','2021-10-07 09:33:43',4,'2021-10-07 09:34:04',4,0,NULL,NULL,NULL,'dce22475-86fa-436c-9e0c-d1af120f9cf2'),(1344,'CITC_HTS_Index Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_Index Data Set\n \n 2021-10-07 07:34:04 UTC\n \n 2021-10-07 09:01: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 1344\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-07 09:34:04',4,'2021-10-07 11:01:32',4,0,NULL,NULL,NULL,'5618efc3-69e9-4c64-adaa-741ed768cbd3'),(1345,'PITC_New_Neg_ART','PITC_New_Neg_ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Neg_ART\n PITC_New_Neg_ART\n \n 2021-10-07 10:13:58 UTC\n \n 2021-10-07 10:16: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 1345\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 12:13:58',4,'2021-10-07 12:16:09',4,0,NULL,NULL,NULL,'6d5bf688-5a2f-4616-82e2-c01a54f14722'),(1346,'PITC_New_Pos_ART','PITC_New_Pos_ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Pos_ART\n PITC_New_Pos_ART\n \n 2021-10-07 10:14:22 UTC\n \n 2021-10-07 10:16: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 1346\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 12:14:22',4,'2021-10-07 12:16:24',4,0,NULL,NULL,NULL,'ea06ed88-160a-467d-9417-76fdb0d46941'),(1347,'PITC_Repeat_Neg_ART','PITC_Repeat_Neg_ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Neg_ART\n PITC_Repeat_Neg_ART\n \n 2021-10-07 10:14:49 UTC\n \n 2021-10-07 10:17: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 1347\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 12:14:49',4,'2021-10-07 12:17:02',4,0,NULL,NULL,NULL,'44e7f485-5997-4262-8fad-c7e92dc4fba5'),(1348,'PITC_Repeat_Pos_ART','PITC_Repeat_Pos_ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Pos_ART\n PITC_Repeat_Pos_ART\n \n 2021-10-07 10:15:14 UTC\n \n 2021-10-07 10:17: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 1348\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 12:15:14',4,'2021-10-07 12:17:16',4,0,NULL,NULL,NULL,'7b43f84d-eb38-48ea-a8c4-7600c51472bf'),(1349,'PITC_HTS_ART','HTS Report for ART Location Clients','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_ART\n HTS Report for ART Location Clients\n \n 2021-10-07 10:26:07 UTC\n \n 2021-10-07 10: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 1349\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','2021-10-07 12:26:07',4,'2021-10-07 12:26:32',4,0,NULL,NULL,NULL,'f75d35bb-2331-4d53-9b78-4caa525d469d'),(1350,'PITC_HTS_ART Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_ART Data Set\n \n 2021-10-07 10:26:32 UTC\n \n 2021-10-07 11:44: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 1350\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-07 12:26:32',4,'2021-10-07 13:44:24',4,0,NULL,NULL,NULL,'48195b40-79bc-4e0e-8157-9001e4389381'),(1351,'CITC_HTS_ART','CITC_HTS_ART','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_ART\n CITC_HTS_ART\n \n 2021-10-07 13:58:15 UTC\n \n 2021-10-07 13:58: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 1351\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','2021-10-07 15:58:15',4,'2021-10-07 15:58:32',4,0,NULL,NULL,NULL,'9ee564ea-f127-40f9-89f3-e6d25a9382a2'),(1352,'CITC_HTS_ART Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_ART Data Set\n \n 2021-10-07 13:58:32 UTC\n \n 2021-10-07 20:54: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 1352\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-07 15:58:32',4,'2021-10-07 22:54:11',4,0,NULL,NULL,NULL,'068e94f1-8873-42de-a660-d8f239c4858c'),(1353,'CITC_New_Neg_ART','CITC_New_Neg_ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Neg_ART\n CITC_New_Neg_ART\n \n 2021-10-07 13:59:29 UTC\n \n 2021-10-07 14:02: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 1353\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 15:59:29',4,'2021-10-07 16:02:13',4,0,NULL,NULL,NULL,'8d97fedb-8b2e-4a68-8adb-82f0f4a9add9'),(1354,'CITC_New_Pos_ART','CITC_New_Pos_ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Pos_ART\n CITC_New_Pos_ART\n \n 2021-10-07 13:59:52 UTC\n \n 2021-10-07 14:02: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 1354\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 15:59:52',4,'2021-10-07 16:02:30',4,0,NULL,NULL,NULL,'dacc0b51-b2c6-42c8-a9d8-22751d857b0f'),(1355,'CITC_Repeat_Pos_ART','CITC_Repeat_Pos_ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Pos_ART\n CITC_Repeat_Pos_ART\n \n 2021-10-07 14:00:29 UTC\n \n 2021-10-07 14:03: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 1355\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 16:00:29',4,'2021-10-07 16:03:06',4,0,NULL,NULL,NULL,'0e5f59f7-089a-4da2-9592-fd5d7b2e3160'),(1356,'CITC_Repeat_Neg_ART','CITC_Repeat_Neg_ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Neg_ART\n CITC_Repeat_Neg_ART\n \n 2021-10-07 14:01:00 UTC\n \n 2021-10-07 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 1356\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 16:01:00',4,'2021-10-07 16:02:53',4,0,NULL,NULL,NULL,'df3ebc14-329c-41a7-b8d7-e2be98f7ce77'),(1357,'PITC_New_Neg_SelfTest','PITC_New_Neg_SelfTest','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Neg_SelfTest\n PITC_New_Neg_SelfTest\n \n 2021-10-07 20:57:55 UTC\n \n 2021-10-07 21:01: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 1357\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 22:57:55',4,'2021-10-07 23:01:55',4,0,NULL,NULL,NULL,'69df4bb7-ba58-44b6-ba62-5a4f7890b8f1'),(1358,'PITC_New_Pos_SelfTest','PITC_New_Pos_SelfTest','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Pos_SelfTest\n PITC_New_Pos_SelfTest\n \n 2021-10-07 20:58:22 UTC\n \n 2021-10-07 21:02: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 1358\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 22:58:22',4,'2021-10-07 23:02:12',4,0,NULL,NULL,NULL,'e826a2b0-18e7-4996-8f74-1db38549a861'),(1359,'PITC_Repeat_Neg_SelfTest','PITC_Repeat_Neg_SelfTest','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Neg_SelfTest\n PITC_Repeat_Neg_SelfTest\n \n 2021-10-07 20:59:27 UTC\n \n 2021-10-07 21:02: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 1359\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 22:59:27',4,'2021-10-07 23:02:31',4,0,NULL,NULL,NULL,'0db20958-582a-4b50-ba86-49b9ef0f64e7'),(1360,'PITC_Repeat_Pos_SelfTest','PITC_Repeat_Pos_SelfTest','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Pos_SelfTest\n PITC_Repeat_Pos_SelfTest\n \n 2021-10-07 20:59:42 UTC\n \n 2021-10-07 21:02: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 1360\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 22:59:42',4,'2021-10-07 23:02:45',4,0,NULL,NULL,NULL,'3708255a-1b1a-421d-a0f1-838a320fa6f4'),(1361,'PITC_HTS_SelfTest','HTS Report for Self Test Clients','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_SelfTest\n HTS Report for Self Test Clients\n \n 2021-10-07 21:05:37 UTC\n \n 2021-10-07 21:05: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 1361\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','2021-10-07 23:05:37',4,'2021-10-07 23:05:45',4,0,NULL,NULL,NULL,'b61f2060-1d4b-4bd7-af32-67db98d50032'),(1362,'PITC_HTS_SelfTest Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_SelfTest Data Set\n \n 2021-10-07 21:05:45 UTC\n \n 2021-10-11 20:55: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 1362\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-07 23:05:45',4,'2021-10-11 22:55:42',4,0,NULL,NULL,NULL,'8e37cf0b-426f-41d1-b2f6-c2a2fc4ca11b'),(1363,' CITC_New_Neg_SelfTest',' CITC_New_Neg_SelfTest','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Neg_SelfTest\n CITC_New_Neg_SelfTest\n \n 2021-10-07 21:50:17 UTC\n \n 2021-10-07 21:53: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 1363\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 23:50:17',4,'2021-10-07 23:53:11',4,0,NULL,NULL,NULL,'4f421a8f-f47c-4c7c-b9ee-645c7598c190'),(1364,' CITC_New_Pos_SelfTest',' CITC_New_Pos_SelfTest','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Pos_SelfTest\n CITC_New_Pos_SelfTest\n \n 2021-10-07 21:50:51 UTC\n \n 2021-10-07 21:53: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 1364\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 23:50:51',4,'2021-10-07 23:53:24',4,0,NULL,NULL,NULL,'b0c652de-795a-49ea-8174-ad6f6876657d'),(1365,' CITC_Repeat_Neg_SelfTest',' CITC_Repeat_Neg_SelfTest','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Neg_SelfTest\n CITC_Repeat_Neg_SelfTest\n \n 2021-10-07 21:51:38 UTC\n \n 2021-10-07 21: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 1365\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 23:51:38',4,'2021-10-07 23:53:44',4,0,NULL,NULL,NULL,'e2d26faf-850c-47a9-929d-2d083f7e8493'),(1366,' CITC_Repeat_Pos_SelfTest',' CITC_Repeat_Pos_SelfTest','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Pos_SelfTest\n CITC_Repeat_Pos_SelfTest\n \n 2021-10-07 21:51:56 UTC\n \n 2021-10-07 21:56: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 1366\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 23:51:56',4,'2021-10-07 23:56:36',4,0,NULL,NULL,NULL,'8a73a6fd-b0fe-47f7-b291-63dd42af9ada'),(1367,'CITC_HTS_SelfTest','CITC_HTS_SelfTest','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_SelfTest\n CITC_HTS_SelfTest\n \n 2021-10-07 21:57:35 UTC\n \n 2021-10-07 21:57: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 1367\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','2021-10-07 23:57:35',4,'2021-10-07 23:57:43',4,0,NULL,NULL,NULL,'bebe6363-836b-48d2-9803-c0e626cb50aa'),(1368,'CITC_HTS_SelfTest Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_SelfTest Data Set\n \n 2021-10-07 21:57:43 UTC\n \n 2021-10-08 12: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 1368\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-07 23:57:43',4,'2021-10-08 14:58:31',4,0,NULL,NULL,NULL,'a4a5bca8-1758-4080-a156-a84df7a62c29'),(1369,'PITC_New_Neg_VMMC','PITC_New_Neg_VMMC','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Neg_VMMC\n PITC_New_Neg_VMMC\n \n 2021-10-08 13:02:52 UTC\n \n 2021-10-08 13:05: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 1369\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-08 15:02:52',4,'2021-10-08 15:05:39',4,0,NULL,NULL,NULL,'d7fc1236-45c7-43d2-9333-bf39b31047a6'),(1370,'PITC_New_Pos_VMMC','PITC_New_Pos_VMMC','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Pos_VMMC\n PITC_New_Pos_VMMC\n \n 2021-10-08 13:03:05 UTC\n \n 2021-10-08 13:06: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 1370\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-08 15:03:05',4,'2021-10-08 15:06:03',4,0,NULL,NULL,NULL,'82030723-8eb6-48ab-aaaf-0b747daaff1c'),(1371,'PITC_Repeat_Pos_VMMC','PITC_Repeat_Pos_VMMC','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Pos_VMMC\n PITC_Repeat_Pos_VMMC\n \n 2021-10-08 13:03:43 UTC\n \n 2021-10-08 13:06: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 1371\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-08 15:03:43',4,'2021-10-08 15:06:32',4,0,NULL,NULL,NULL,'ab25dc35-65f6-444d-82a0-71167a014c3b'),(1372,'PITC_Repeat_Neg_VMMC','PITC_Repeat_Neg_VMMC','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Neg_VMMC\n PITC_Repeat_Neg_VMMC\n \n 2021-10-08 13:04:03 UTC\n \n 2021-10-08 13:06: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 1372\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-08 15:04:03',4,'2021-10-08 15:06:22',4,0,NULL,NULL,NULL,'236df974-039e-411b-9ce8-09e74f743950'),(1373,'PITC_HTS_VMMC','PITC_HTS_VMMC','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_VMMC\n PITC_HTS_VMMC\n \n 2021-10-08 13:07:49 UTC\n \n 2021-10-08 13:08: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 1373\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','2021-10-08 15:07:49',4,'2021-10-08 15:08:14',4,0,NULL,NULL,NULL,'a58c74c3-1edc-4d4b-8ac2-0ce3e4839c7d'),(1374,'PITC_HTS_VMMC Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_VMMC Data Set\n \n 2021-10-08 13:08:14 UTC\n \n 2021-10-09 23:08: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 1374\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-08 15:08:14',4,'2021-10-10 01:08:00',4,0,NULL,NULL,NULL,'43f1ef2d-1b0d-46cf-96d3-f357f2d893ab'),(1375,'CITC_New_Neg_VMMC','CITC_New_Neg_VMMC','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Neg_VMMC\n CITC_New_Neg_VMMC\n \n 2021-10-09 22:54:44 UTC\n \n 2021-10-09 22:59: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 1375\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-10 00:54:44',4,'2021-10-10 00:59:55',4,0,NULL,NULL,NULL,'e735dc8b-4e55-46b0-98be-9d35609cdcd1'),(1376,'CITC_New_Pos_VMMC','CITC_New_Pos_VMMC','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Pos_VMMC\n CITC_New_Pos_VMMC\n \n 2021-10-09 22:54:57 UTC\n \n 2021-10-09 23:00: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 1376\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-10 00:54:57',4,'2021-10-10 01:00:23',4,0,NULL,NULL,NULL,'33e10e5c-b210-4364-bb0a-834ef9fef156'),(1377,'CITC_Repeat_Neg_VMMC','CITC_Repeat_Neg_VMMC','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Neg_VMMC\n CITC_Repeat_Neg_VMMC\n \n 2021-10-09 22:55:46 UTC\n \n 2021-10-09 23:00: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 1377\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-10 00:55:46',4,'2021-10-10 01:00:47',4,0,NULL,NULL,NULL,'787c96e2-053c-4c5a-bac9-e6b2cdc11b3b'),(1378,'CITC_Repeat_Pos_VMMC','CITC_Repeat_Pos_VMMC','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Pos_VMMC\n CITC_Repeat_Pos_VMMC\n \n 2021-10-09 22:56:57 UTC\n \n 2021-10-09 23:02: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 1378\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-10 00:56:57',4,'2021-10-10 01:02:21',4,0,NULL,NULL,NULL,'abbf2da2-d3f1-4ec4-bcf6-bc4f172771c2'),(1379,'CITC_HTS_VMMC','CITC_HTS_VMMC','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_VMMC\n CITC_HTS_VMMC\n \n 2021-10-09 23:06:10 UTC\n \n 2021-10-09 23:06: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 1379\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','2021-10-10 01:06:10',4,'2021-10-10 01:06:57',4,0,NULL,NULL,NULL,'893154ae-6213-4759-aaad-6662e595eabe'),(1380,'CITC_HTS_VMMC Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_VMMC Data Set\n \n 2021-10-09 23:06:57 UTC\n \n 2021-10-10 22:32: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 1380\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-10 01:06:57',4,'2021-10-11 00:32:14',4,0,NULL,NULL,NULL,'03501008-0bd0-444d-9563-ccbc878fa540'),(1381,'Missed Appointments Under 28 Days Quarterly','Missed Appointments Under 28 Days for quarterly reporting','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Missed Appointments Under 28 Days Quarterly\n Missed Appointments Under 28 Days for quarterly reporting\n \n 2021-11-24 11:15:40 UTC\n \n 2021-11-24 12:16: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 1381\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','2021-11-24 13:15:40',4,'2021-11-24 14:16:41',4,0,NULL,NULL,NULL,'a8c08a78-5ad7-47d0-a164-32023f01d8c3'),(1382,'Missed Under 28 Days Quarterly Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Missed Under 28 Days Quarterly Data Set\n \n 2021-11-24 11:15:50 UTC\n \n 2021-11-24 11:36: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 1382\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n MissedF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n MissedF10-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n MissedF15-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n MissedF20-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n MissedF25-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n MissedF30-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n MissedF35-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n MissedF40-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n MissedF45-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n MissedF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n MissedF50P\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n MissedF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n MissedM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n MissedM10-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n MissedM15-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n MissedM20-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n MissedM25-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n MissedM30-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n MissedM35-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n MissedM40-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n MissedM45-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n MissedM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n MissedM50P\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n MissedM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n','2021-11-24 13:15:50',4,'2021-11-24 13:36:46',4,0,NULL,NULL,NULL,'d465ee4d-712a-468a-afbb-69a049e009c5'),(1383,'Test - Intakes Percentage','Test - Intakes Percentage','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Test - Intakes Percentage\n Test - Intakes Percentage\n \n 2021-12-08 11:44:27 UTC\n \n 2021-12-08 11:45: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 1383\n','2021-12-08 13:44:27',4,'2021-12-08 13:45:08',4,0,NULL,NULL,NULL,'25bec7c7-30cd-49dd-9995-73b72f766ab7'),(1384,'TPT Started eRegister Process Report Weekly','TPT Started for eRegister Process Report','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TPT Started eRegister Process Report Weekly\n TPT Started for eRegister Process Report\n \n 2021-12-08 14:52:04 UTC\n \n 2021-12-08 16:16: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 1384\n Select Id \nfrom \n(select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier \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 )as A \n \n where Id in ( \n select distinct patient.patient_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n where concept_id = 2227 and value_coded = 2146 \n AND o.obs_datetime >=:startDate and o.obs_datetime <=:endDate \n \n )\n','2021-12-08 16:52:04',4,'2021-12-08 18:16:37',4,0,NULL,NULL,NULL,'90367439-c46f-4021-9858-29280bb738c7'),(1385,'TPT Started this Month','TPT Started this Month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TPT Started this Month\n TPT Started this Month\n \n 2021-12-08 16:20:18 UTC\n \n 2021-12-08 16:20: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 1385\n Select Id \nfrom \n(select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier \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 )as A \n \n where Id in ( \n select distinct patient.patient_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n where concept_id = 2227 and value_coded = 2146 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n )\n','2021-12-08 18:20:18',4,'2021-12-08 18:20:42',4,0,NULL,NULL,NULL,'62e8947b-9360-430f-9708-f61d0adb8cf8'),(1386,'TPT Completed this Month','TPT Completed this Month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TPT Completed this Month\n TPT Completed this Month\n \n 2021-12-13 12:12:58 UTC\n \n 2021-12-13 12:13: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 1386\n Select Id \nfrom \n(select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier \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 )as A \n \n where Id in ( \n select distinct os.person_id \n from obs os \n where concept_id = 4821 \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','2021-12-13 14:12:58',4,'2021-12-13 14:13:15',4,0,NULL,NULL,NULL,'05b50fa0-aa34-4c91-b02e-cd4e159533f1'),(1387,'TPT Completed eRegister Process Report Weekly','TPT Completed eRegister Process Report Weekly','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TPT Completed eRegister Process Report Weekly\n TPT Completed eRegister Process Report Weekly\n \n 2021-12-13 12:22:47 UTC\n \n 2021-12-13 12:23: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 1387\n Select Id \nfrom \n(select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier \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 )as A \n \n where Id in ( \n select distinct patient.patient_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n where concept_id = 4821 \n AND o.obs_datetime >=:startDate and o.obs_datetime <=:endDate \n \n )\n','2021-12-13 14:22:47',4,'2021-12-13 14:23:06',4,0,NULL,NULL,NULL,'3bc4a33c-71d7-483f-8c8e-db247e44e2bc'),(1388,'VL-04 VL tests performed_recent_3months','VL-04 VL tests performed in the recent 3 months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-04 VL tests performed_recent_3months\n VL-04 VL tests performed in the recent 3 months\n \n 2021-12-15 13:35:47 UTC\n \n 2021-12-16 09:05: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 1388\n Select person_id \nFROM \n(select oss.person_id, MAX(oss.obs_datetime) as max_observation,CAST(Max(oss.value_datetime) as DATE) as Blood_Drawn_Date \n from obs oss \n where oss.concept_id = 4267 and oss.voided=0 \n and oss.value_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id) as vl_tests_preformed\n','2021-12-15 15:35:47',4,'2021-12-16 11:05:21',4,0,NULL,NULL,NULL,'04eb3953-22d9-4733-aa50-4a8ed4742edf'),(1389,'TPT Continued eRegister Process Report Weekly','Clients Currently on TPT - eRegister Process Report Weekly','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TPT Continued eRegister Process Report Weekly\n Clients Currently on TPT - eRegister Process Report Weekly\n \n 2021-12-16 10:37:22 UTC\n \n 2021-12-16 10:51: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 1389\n Select Id \nfrom \n(select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier \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 )as A \n \n where Id in ( \n select distinct patient.patient_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n where concept_id = 2227 -- and value_coded = 2146 \n AND o.obs_datetime >=:startDate and o.obs_datetime <=:endDate \n \n )\n','2021-12-16 12:37:22',4,'2021-12-16 12:51:15',4,0,NULL,NULL,NULL,'2a45ccbb-5d49-46a5-9c14-86a68c658c0f'),(1390,'TPT Continuing this Month','Clients Continuing TPT this month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TPT Continuing this Month\n Clients Continuing TPT this month\n \n 2021-12-16 10:50:30 UTC\n \n 2021-12-16 10:52: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 1390\n Select Id \nfrom \n(select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier \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 )as A \n \n where Id in ( \n select distinct os.person_id \n from obs os \n where concept_id = 4821 \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','2021-12-16 12:50:30',4,'2021-12-16 12:52:57',4,0,NULL,NULL,NULL,'8b56b3a8-d45a-413e-81d9-b47db2336814'),(1391,'CI54:TPT Started_Weekly','CI54:TPT Started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI54:TPT Started_Weekly\n CI54:TPT Started\n \n 2021-12-16 11:02:11 UTC\n \n 2021-12-16 11:04: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 1391\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 13:02:11',4,'2021-12-16 13:04:49',4,0,NULL,NULL,NULL,'d12bddcf-0bfa-4c0b-96d4-fed20d3251d4'),(1392,'CI55:TPT Continued Weekly','CI55:TPT Continued Weekly','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI55:TPT Continued Weekly\n CI55:TPT Continued Weekly\n \n 2021-12-16 11:06:12 UTC\n \n 2021-12-16 11:07: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 1392\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 13:06:12',4,'2021-12-16 13:07:06',4,0,NULL,NULL,NULL,'6444a6c5-e484-4a40-911e-98ed6c43112d'),(1393,'CI56:TPT Completed Weekly','CI56:TPT Completed Weekly','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI56:TPT Completed Weekly\n CI56:TPT Completed Weekly\n \n 2021-12-16 11:08:33 UTC\n \n 2021-12-16 11:17: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 1393\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 13:08:33',4,'2021-12-16 13:17:21',4,0,NULL,NULL,NULL,'b78d514c-0203-44a4-8bc2-e04e521d3eff'),(1394,'CI57:VL Blood Draws in recent 3 months','CI57:VL Blood Draws recent 3 months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI57:VL Blood Draws in recent 3 months\n CI57:VL Blood Draws recent 3 months\n \n 2021-12-16 11:20:31 UTC\n \n 2021-12-16 11:22: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 1394\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 13:20:31',4,'2021-12-16 13:22:32',4,0,NULL,NULL,NULL,'db80bf53-873d-4c0c-8847-726847b0c417'),(1395,'CI58:VL Results received within 3 months','CI58:VL Results received within 3 months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI58:VL Results received within 3 months\n CI58:VL Results received within 3 months\n \n 2021-12-16 11:24:28 UTC\n \n 2021-12-16 11:25: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 1395\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 13:24:28',4,'2021-12-16 13:25:37',4,0,NULL,NULL,NULL,'5b8fbea7-884a-4e64-ae29-48732ba65c3a'),(1396,'CI59:VL Results received this month','CI59:VL Results received this month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI59:VL Results received this month\n CI59:VL Results received this month\n \n 2021-12-16 11:28:21 UTC\n \n 2021-12-16 11:29: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 1396\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 13:28:21',4,'2021-12-16 13:29:17',4,0,NULL,NULL,NULL,'019b40c1-d072-414e-9ffd-a6f00f6eab86'),(1397,'CI60:Pending Results within 3 months','CI60:Pending Results within 3 months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI60:Pending Results within 3 months\n CI60:Pending Results within 3 months\n \n 2021-12-16 12:02:36 UTC\n \n 2021-12-16 12:03: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 1397\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 14:02:36',4,'2021-12-16 14:03:44',4,0,NULL,NULL,NULL,'3f59f3a6-d116-4fce-ac20-e739c9cfefa6'),(1398,'CI61:Pending Results within 2 months','CI61:Pending Results within 2 months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI61:Pending Results within 2 months\n CI61:Pending Results within 2 months\n \n 2021-12-16 12:05:54 UTC\n \n 2021-12-16 12:06: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 1398\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 14:05:54',4,'2021-12-16 14:06:36',4,0,NULL,NULL,NULL,'a8dcaa40-a96f-4714-a161-c9493a75ba91'),(1399,'CI62:Pending Results within 1 month','CI62:Pending Results within 1 month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI62:Pending Results within 1 month\n CI62:Pending Results within 1 month\n \n 2021-12-16 12:07:27 UTC\n \n 2021-12-16 12:08: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 1399\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 14:07:27',4,'2021-12-16 14:08:04',4,0,NULL,NULL,NULL,'cb06df8b-0d0f-415c-ad52-322786e3e3fc'),(1401,'Discordant Couple','Couple discordant results','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Discordant Couple\n Couple discordant results\n \n 2022-02-16 18:59:38 UTC\n \n 2022-02-17 18:55: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 1401\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 \n (select o.person_id \n from obs o \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 \n patient_identifier.identifier_type IN (3,5) AND patient_identifier.preferred=1 \n \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n where concept_id in (4225) and value_coded in (2146) \n Group by o.person_id \n)\n','2022-02-17 00:29:38',4,'2022-02-18 00:25:55',4,0,NULL,NULL,NULL,'09606416-9fdb-404a-a23f-2670030a98c2'),(1402,'Indeterminate results','indeterminate and inconclusive test results','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Indeterminate results\n indeterminate and inconclusive test results\n \n 2022-02-17 03:45:12 UTC\n \n 2022-02-17 03:57: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 1402\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 \n (select o.person_id as Id \n from obs o \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 \n patient_identifier.identifier_type IN (3,5) AND patient_identifier.preferred=1 \n \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n where concept_id in (4223) and value_coded in (4220) \n Group by o.person_id)\n','2022-02-17 09:15:12',4,'2022-02-17 09:27:02',4,0,NULL,NULL,NULL,'91361707-3e26-4592-b606-0d5b76fed7f5'),(1403,'Couples Only','HTS Clients Tested as Couple','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Couples Only\n HTS Clients Tested as Couple\n \n 2022-02-17 03:58:23 UTC\n \n 2022-02-24 07: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 1403\n select distinct o.person_id \n from obs o inner join location l on o.location_id = l.location_id \n where (o.location_id =:location or parent_location =:location) \n and o.person_id in \n (select o.person_id \n from obs o \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 \n patient_identifier.identifier_type IN (3,5) AND patient_identifier.preferred=1 \n \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n where concept_id in (2166) and value_coded in (2146) \n Group by o.person_id)\n','2022-02-17 09:28:23',4,'2022-02-24 12:30:31',4,0,NULL,NULL,NULL,'7a60cfbe-7e8b-49bb-8f69-bf04e37c37e9'),(1404,'HTS Clients Screened ','Number of HTS Clients Screened for TB','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Clients Screened \n Number of HTS Clients Screened for TB\n \n 2022-02-17 04:07:32 UTC\n \n 2022-03-17 10:26: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 1404\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 \n (select o.person_id \n from obs o \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 \n patient_identifier.identifier_type IN (3) AND patient_identifier.preferred=1 \n \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n where concept_id in (2294) and value_coded in (2146) \n Group by o.person_id)\n','2022-02-17 04:07:32',4,'2022-03-17 10:26:05',4,0,NULL,NULL,NULL,'5a029d5e-f4ba-4e2c-8dc6-ba01d0ca45af'),(1405,'Confirmed Negative','HTS Confirmed Negative Clients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Confirmed Negative\n HTS Confirmed Negative Clients\n \n 2022-02-17 12:05:47 UTC\n \n 2022-02-17 12:14: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 1405\n select distinct o.person_id \n from obs o inner join location l on o.location_id = l.location_id \n where (o.location_id =:location or parent_location =:location) \n and o.person_id in \n (select o.person_id \n from obs o \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 \n patient_identifier.identifier_type IN (3,5) AND patient_identifier.preferred=1 \n \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n where concept_id in (2165) and value_coded in (1016) \n Group by o.person_id)\n','2022-02-17 17:35:47',4,'2022-02-17 17:44:51',4,0,NULL,NULL,NULL,'c9c50904-153c-4517-b462-5df83b4fd9b9'),(1406,'Confirmed Positives','HTS Confirmed Positive Clients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Confirmed Positives\n HTS Confirmed Positive Clients\n \n 2022-02-17 12:17:04 UTC\n \n 2022-02-17 12: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 1406\n select distinct o.person_id \n from obs o inner join location l on o.location_id = l.location_id \n where (o.location_id =:location or parent_location =:location) \n and o.person_id in \n (select o.person_id \n from obs o \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 \n patient_identifier.identifier_type IN (3,5) AND patient_identifier.preferred=1 \n \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n where concept_id in (2165) and value_coded in (1738) \n Group by o.person_id)\n','2022-02-17 17:47:04',4,'2022-02-17 17:49:20',4,0,NULL,NULL,NULL,'44a79d1e-c5ea-44ab-b6df-0c21abaa9a38'),(1407,'Indeterminate results','Total Indeterminate results','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.SqlIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Indeterminate results\n Total Indeterminate results\n \n 2022-02-17 17:40:50 UTC\n \n','2022-02-17 23:10:50',4,NULL,NULL,0,NULL,NULL,NULL,'13337249-1e1c-42a4-9f3e-edacbb906e5d'),(1408,'Indeterminate results','Total Indeterminate results','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Indeterminate results\n Total Indeterminate results\n \n 2022-02-17 17:42:25 UTC\n \n 2022-02-17 17: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 1408\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-02-17 23:12:25',4,'2022-02-17 23:16:50',4,0,NULL,NULL,NULL,'e4e5a5d1-5d70-4a2e-83fb-902c382967d5'),(1409,'HTS Screened','Number of HTS Clients screened for TB','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Screened\n Number of HTS Clients screened for TB\n \n 2022-02-17 17:49:05 UTC\n \n 2022-02-17 17:55: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 1409\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-02-17 23:19:05',4,'2022-02-17 23:25:54',4,0,NULL,NULL,NULL,'5abf9b9c-5225-4470-a455-bcc7ca6addca'),(1411,'HTS Clients Screened for TB Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Clients Screened for TB Data Set\n \n 2022-02-17 17:59:08 UTC\n \n 2022-02-17 18:30: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 1411\n \n \n DM_Sex\n \n \n \n \n \n \n \n \n HTS_Female\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 HTS_Males\n \n \n \n \n DM_Sex\n Males\n \n \n \n \n \n','2022-02-17 23:29:08',4,'2022-02-18 00:00:56',4,0,NULL,NULL,NULL,'86204394-0168-468b-b3d8-0de0beb04bc2'),(1412,'Couples Only','HTS Clients tested as couples','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Couples Only\n HTS Clients tested as couples\n \n 2022-02-17 18:39:17 UTC\n \n 2022-02-17 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 1412\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-02-18 00:09:17',4,'2022-02-18 00:11:37',4,0,NULL,NULL,NULL,'fa71acc6-bc29-4927-bbc4-d49906763b94'),(1413,'Discordant Results','Discordant Test Resultes','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Discordant Results\n Discordant Test Resultes\n \n 2022-02-17 18:53:30 UTC\n \n 2022-02-17 18:57: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 1413\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-02-18 00:23:30',4,'2022-02-18 00:27:04',4,0,NULL,NULL,NULL,'73ea8489-1fa9-46ab-a2ce-6b6b2d73a33e'),(1414,'Confirmed Negatives','Number of Confirmed Negative Results','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Confirmed Negatives\n Number of Confirmed Negative Results\n \n 2022-02-17 18:59:07 UTC\n \n 2022-02-17 19:05: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 1414\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-02-18 00:29:07',4,'2022-02-18 00:35:44',4,0,NULL,NULL,NULL,'e78ac003-c014-430b-806c-8f71e0b33164'),(1415,'Confirmed Positives','Number of confirmed positive results','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Confirmed Positives\n Number of confirmed positive results\n \n 2022-02-17 19:07:25 UTC\n \n 2022-02-17 19:08: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 1415\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-02-18 00:37:25',4,'2022-02-18 00:38:40',4,0,NULL,NULL,NULL,'c43780c6-a70b-4cca-9821-af8fac2e5b75'),(1417,'Total Indeterminate Results Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Total Indeterminate Results Data Set\n \n 2022-02-17 19:12:45 UTC\n \n 2022-02-17 19:19: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 1417\n \n \n \n \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','2022-02-18 00:42:45',4,'2022-02-18 00:49:17',4,0,NULL,NULL,NULL,'d8134c4d-7b2d-4421-93b5-986cf5263b17'),(1419,'Couples Only Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Couples Only Data Set\n \n 2022-02-17 19:22:38 UTC\n \n 2022-02-17 19:23: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 1419\n \n \n \n \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','2022-02-18 00:52:38',4,'2022-02-18 00:53:37',4,0,NULL,NULL,NULL,'5f221d24-9b0f-4b56-8659-2262fa6383ca'),(1421,'Discordant Test Results Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Discordant Test Results Data Set\n \n 2022-02-17 19:25:59 UTC\n \n 2022-02-17 19:26: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 1421\n \n \n \n \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','2022-02-18 00:55:59',4,'2022-02-18 00:56:57',4,0,NULL,NULL,NULL,'fe57a3d6-6ea3-4878-ab19-d3b2bc676b18'),(1422,'HTS_Post_Test_Counseling','HTS_Post_Test_Counseling','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS_Post_Test_Counseling\n HTS_Post_Test_Counseling\n \n 2022-02-17 19:30:06 UTC\n \n 2022-02-17 19:54: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 1422\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','2022-02-18 01:00:06',4,'2022-02-18 01:24:15',4,0,NULL,NULL,NULL,'a37e3f91-87d6-4126-b164-4888fa187f93'),(1423,'Number of Confirmatory Test Results Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Number of Confirmatory Test Results Data Set\n \n 2022-02-17 19:30:22 UTC\n \n 2022-02-24 18:31: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 1423\n \n \n DM_Sex\n \n \n \n \n \n \n \n \n Couples\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 Distri_Kit\n \n \n \n \n \n \n \n \n \n HTS_Female\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n \n \n \n HTS_Males\n \n \n \n \n DM_Sex\n Males\n \n \n \n \n \n Ind_Res\n \n \n \n \n \n \n \n \n \n Retur_Kits\n \n \n \n \n \n \n \n \n \n con_neg\n \n \n \n \n \n \n \n \n \n con_pos\n \n \n \n \n \n \n \n \n \n disc_res\n \n \n \n \n \n \n \n \n \n','2022-02-18 01:00:22',4,'2022-02-25 00:01:20',4,0,NULL,NULL,NULL,'e3eaeee4-8afa-4090-a2c5-72662d743f68'),(1425,'Distributed Self test Kits','Total HTS Self Test Distributed Kits','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Distributed Self test Kits\n Total HTS Self Test Distributed Kits\n \n 2022-02-24 13:03:04 UTC\n \n 2024-01-31 15:47: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 1425\n select distinct o.obs_id \n from obs o \n where o.obs_id in ( \n select o.person_id \n from obs o \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 \n patient_identifier.identifier_type IN (3,5) AND patient_identifier.preferred=1 \n INNER JOIN location l on o.location_id = l.location_id and l.retired=0 \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n where concept_id in (4968) \n and (o.location_id = :location or parent_location = :location) \n Union All \n select o.person_id \n from obs o \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 \n patient_identifier.identifier_type IN (3,5) AND patient_identifier.preferred=1 \n INNER JOIN location l on o.location_id = l.location_id and l.retired=0 \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n where concept_id in (4845) and value_coded in (4822) \n and (o.location_id = :location or parent_location = :location) \n )\n','2022-02-24 18:33:04',4,'2024-01-31 21:17:34',4,0,NULL,NULL,NULL,'7fb1f754-6cb8-4d98-bbeb-49a931f97994'); -INSERT INTO `serialized_object` VALUES (1426,'Distributed Self Test Kits','Total Distributed Self Test Kits','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Distributed Self Test Kits\n Total Distributed Self Test Kits\n \n 2022-02-24 13:33:06 UTC\n \n 2022-02-24 18:11: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 1426\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-02-24 19:03:06',4,'2022-02-24 23:41:54',4,0,NULL,NULL,NULL,'45e24163-6e6a-44a8-a168-1960f92e6664'),(1427,'HTS Self Test Kits Returned','Total HTS Self Test Kits Returned','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Self Test Kits Returned\n Total HTS Self Test Kits Returned\n \n 2022-02-24 18:14:58 UTC\n \n 2022-02-24 18:25: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 1427\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-02-24 23:44:58',4,'2022-02-24 23:55:27',4,0,NULL,NULL,NULL,'e448334c-d0c9-46cd-8041-45a9492aecb7'),(1428,'Returned Self Test Kits','Total Returned Self Test Kits','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Returned Self Test Kits\n Total Returned Self Test Kits\n \n 2022-02-24 18:19:33 UTC\n \n 2024-01-31 15:51: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 1428\n select distinct o.obs_id \n from obs o \n where o.obs_id in ( \n select o.person_id \n from obs o \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 \n patient_identifier.identifier_type IN (3,5) AND patient_identifier.preferred=1 \n INNER JOIN location l on o.location_id = l.location_id and l.retired=0 \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n where concept_id in (4844) and value_coded not in (2148) \n and (o.location_id = :location or parent_location = :location) \n Group by o.person_id \n )\n','2022-02-24 23:49:33',4,'2024-01-31 21:21:23',4,0,NULL,NULL,NULL,'fbebdef1-7e03-4061-b525-95f86632ab49'),(1429,'ART Clients Stopped','ART Clients who stopped treatment in that month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART Clients Stopped\n ART Clients who stopped treatment in that month\n \n 2022-04-28 08:52:48 UTC\n \n 2022-04-28 08:54: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 1429\n select os.person_id \n from obs os \n inner join location l on os.location_id = l.location_id \n where os.concept_id = 3701 and os.voided = 0 \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.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3767 and o.value_coded = 2297 \n and o.voided = 0 \n \n )\n','2022-04-28 08:52:48',4,'2022-04-28 08:54:53',4,0,NULL,NULL,NULL,'2ea61d1f-e032-452e-bc0c-5ffb80c1a256'),(1430,'Clients given 4L weighing 0-3.9kg','Clients given 4L weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 0-3.9kg\n Clients given 4L weighing 0-3.9kg\n \n 2022-06-30 09:34:15 UTC\n \n 2023-08-03 10:37: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 1430\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:34:15',4,'2023-08-03 12:37:31',4,0,NULL,NULL,NULL,'1cbd9712-0dde-45fa-977c-98e3fd65681b'),(1431,'Clients given 4C weighing 0-3.9kg','Clients given 4C weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 0-3.9kg\n Clients given 4C weighing 0-3.9kg\n \n 2022-06-30 09:37:12 UTC\n \n 2023-07-27 10:09: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 1431\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:37:12',4,'2023-07-27 12:09:00',4,0,NULL,NULL,NULL,'9cd0146e-b566-4e02-9d37-da46810c833e'),(1432,'Clients given 4L weighing 4-5.9kg','Clients given 4L weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 4-5.9kg\n Clients given 4L weighing 4-5.9kg\n \n 2022-06-30 09:37:43 UTC\n \n 2023-08-03 10:43: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 1432\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:37:43',4,'2023-08-03 12:43:41',4,0,NULL,NULL,NULL,'aecca82d-d3c2-429d-acb2-56e1657ce6db'),(1433,'Clients given 4L weighing 6-9.9kg','Clients given 4L weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 6-9.9kg\n Clients given 4L weighing 6-9.9kg\n \n 2022-06-30 09:39:53 UTC\n \n 2023-08-03 10:44: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 1433\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:39:53',4,'2023-08-03 12:44:44',4,0,NULL,NULL,NULL,'1758b50a-2a2c-4b2c-b795-355255878304'),(1434,'Clients given 4L weighing 10-13.9kg','Clients given 4L weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 10-13.9kg\n Clients given 4L weighing 10-13.9kg\n \n 2022-06-30 09:42:34 UTC\n \n 2023-08-03 10:40: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 1434\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:42:34',4,'2023-08-03 12:40:14',4,0,NULL,NULL,NULL,'2c470abf-a5dc-4c5e-a1f0-dc85cc66b111'),(1435,'Clients given 4C weighing 4-5.9kg','Clients given 4C weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 4-5.9kg\n Clients given 4C weighing 4-5.9kg\n \n 2022-06-30 09:43:58 UTC\n \n 2023-07-27 10:06: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 1435\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:43:58',4,'2023-07-27 12:06:25',4,0,NULL,NULL,NULL,'ae72a1f2-5b35-4736-8a3d-d09eeaafaaf1'),(1436,'Clients given 4L weighing 14-19.9kg','Clients given 4L weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 14-19.9kg\n Clients given 4L weighing 14-19.9kg\n \n 2022-06-30 09:44:49 UTC\n \n 2023-08-03 10:41: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 1436\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:44:49',4,'2023-08-03 12:41:10',4,0,NULL,NULL,NULL,'c0c8885b-814c-4cb2-8c23-c10871a2b76d'),(1437,'Clients given 4L weighing 20-24.9kg','Clients given 4L weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 20-24.9kg\n Clients given 4L weighing 20-24.9kg\n \n 2022-06-30 09:45:58 UTC\n \n 2023-08-03 10:41: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 1437\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 \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 \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 (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','2022-06-30 11:45:58',4,'2023-08-03 12:41:51',4,0,NULL,NULL,NULL,'889cb817-6500-4ae1-9f84-e1ec42b46c00'),(1438,'Clients given 4L weighing 25-34.9kg','Clients given 4L weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 25-34.9kg\n Clients given 4L weighing 25-34.9kg\n \n 2022-06-30 09:47:36 UTC\n \n 2023-08-03 10:42: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 1438\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:47:36',4,'2023-08-03 12:42:36',4,0,NULL,NULL,NULL,'51076831-4759-4f7d-8d57-47fb8862e61c'),(1439,'Clients given 4L weighing >=35','Clients given 4L weighing >=35','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing >=35\n Clients given 4L weighing >=35\n \n 2022-06-30 09:48:54 UTC\n \n 2023-08-03 10:36: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 1439\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:48:54',4,'2023-08-03 12:36:25',4,0,NULL,NULL,NULL,'3ba57d29-931d-454e-916c-9e0c0e90d805'),(1440,'Clients given 4C weighing 6-9.9kg','Clients given 4C weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 6-9.9kg\n Clients given 4C weighing 6-9.9kg\n \n 2022-06-30 09:49:04 UTC\n \n 2023-07-27 10:06: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 1440\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:49:04',4,'2023-07-27 12:06:55',4,0,NULL,NULL,NULL,'d3d16a07-4319-4d63-82a2-4f47f7928a00'),(1441,'Clients given 4C weighing 10-13.9kg','Clients given 4C weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 10-13.9kg\n Clients given 4C weighing 10-13.9kg\n \n 2022-06-30 09:50:51 UTC\n \n 2023-07-27 10:01: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 1441\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:50:51',4,'2023-07-27 12:01:01',4,0,NULL,NULL,NULL,'09622f4b-49d5-4214-9eb4-7de4cae57a9d'),(1442,'Clients given 4K weighing 0-3.9kg','Clients given 4K weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 0-3.9kg\n Clients given 4K weighing 0-3.9kg\n \n 2022-06-30 09:52:14 UTC\n \n 2023-07-27 12:56: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 1442\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:52:14',4,'2023-07-27 14:56:47',4,0,NULL,NULL,NULL,'0f76ed94-e4f8-4f94-9bc4-4adbba1c66c1'),(1443,'Clients given 4C weighing 14-19.9kg','Clients given 4C weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 14-19.9kg\n Clients given 4C weighing 14-19.9kg\n \n 2022-06-30 09:53:51 UTC\n \n 2023-08-15 13:35: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 1443\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:53:51',4,'2023-08-15 15:35:14',4,0,NULL,NULL,NULL,'034244be-ee9b-4c5f-9c05-b69eefad3051'),(1444,'Clients given 4K weighing 4-5.9kg','Clients given 4K weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 4-5.9kg\n Clients given 4K weighing 4-5.9kg\n \n 2022-06-30 09:53:56 UTC\n \n 2023-07-27 12:58: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 1444\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:53:56',4,'2023-07-27 14:58:37',4,0,NULL,NULL,NULL,'fe700a2f-6c6b-4ab5-8692-4171cb0dc27c'),(1445,'Clients given 4K weighing 6-9.9kg','Clients given 4K weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 6-9.9kg\n Clients given 4K weighing 6-9.9kg\n \n 2022-06-30 09:55:49 UTC\n \n 2023-07-27 12:59: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 1445\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:55:49',4,'2023-07-27 14:59:00',4,0,NULL,NULL,NULL,'db5d6766-3a33-43c4-9732-a4d83ce9b1ea'),(1446,'Clients given 4K weighing 10-13.9kg','Clients given 4K weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 10-13.9kg\n Clients given 4K weighing 10-13.9kg\n \n 2022-06-30 09:56:49 UTC\n \n 2023-07-27 12:57: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 1446\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:56:49',4,'2023-07-27 14:57:10',4,0,NULL,NULL,NULL,'494aa500-1c2d-45b2-b6ba-aa987b52622a'),(1447,'Clients given 4K weighing 14-19.9kg','Clients given 4K weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 14-19.9kg\n Clients given 4K weighing 14-19.9kg\n \n 2022-06-30 09:58:26 UTC\n \n 2023-07-27 12:57: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 1447\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:58:26',4,'2023-07-27 14:57:30',4,0,NULL,NULL,NULL,'480ac769-5b88-4485-8885-03322fa49fc8'),(1448,'Clients given 4K weighing 20-24.9kg','Clients given 4K weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 20-24.9kg\n Clients given 4K weighing 20-24.9kg\n \n 2022-06-30 09:59:23 UTC\n \n 2023-07-27 12:57: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 1448\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 \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 \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 (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','2022-06-30 11:59:23',4,'2023-07-27 14:57:51',4,0,NULL,NULL,NULL,'3bd2b9e5-01e8-43ac-a17a-3912a89d7ff1'),(1449,'Clients given 4K weighing 25-34.9kg','Clients given 4K weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 25-34.9kg\n Clients given 4K weighing 25-34.9kg\n \n 2022-06-30 10:01:21 UTC\n \n 2023-07-27 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 1449\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:01:21',4,'2023-07-27 14:58:15',4,0,NULL,NULL,NULL,'921f9499-c27b-4b41-95e0-b85292fa2f92'),(1450,'Clients given 4K weighing >=35kg','Clients given 4K weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing >=35kg\n Clients given 4K weighing >=35kg\n \n 2022-06-30 10:02:42 UTC\n \n 2023-07-27 12:56: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 1450\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:02:42',4,'2023-07-27 14:56:23',4,0,NULL,NULL,NULL,'3229cff2-e047-4073-90c1-e06e867b402b'),(1451,'Clients given 4C weighing 20-24.9kg','Clients given 4C weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 20-24.9kg\n Clients given 4C weighing 20-24.9kg\n \n 2022-06-30 10:02:57 UTC\n \n 2023-07-27 10:03: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 1451\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 \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 \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 (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','2022-06-30 12:02:57',4,'2023-07-27 12:03:19',4,0,NULL,NULL,NULL,'9e67fab4-3382-49c7-bc4a-8e6f95ecd7ff'),(1452,'Clients given 4C weighing 25-34.9kg','Clients given 4C weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 25-34.9kg\n Clients given 4C weighing 25-34.9kg\n \n 2022-06-30 10:04:55 UTC\n \n 2023-07-27 10:05: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 1452\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:04:55',4,'2023-07-27 12:05:26',4,0,NULL,NULL,NULL,'1e41db8d-aca6-471d-af67-bddf792eb12e'),(1453,'Clients given 4C weighing >=35kg','Clients given 4C weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing >=35kg\n Clients given 4C weighing >=35kg\n \n 2022-06-30 10:06:32 UTC\n \n 2023-07-27 10:08: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 1453\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:06:32',4,'2023-07-27 12:08:27',4,0,NULL,NULL,NULL,'9bb26987-59cb-48b8-8235-502a3d2f52b4'),(1454,'Clients given 4J weighing 0-3.9kg','Clients given 4J weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 0-3.9kg\n Clients given 4J weighing 0-3.9kg\n \n 2022-06-30 10:07:54 UTC\n \n 2023-07-27 10:59: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 1454\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:07:54',4,'2023-07-27 12:59:20',4,0,NULL,NULL,NULL,'b4265cc6-ac60-4aeb-ba91-ef213a6d949e'),(1455,'Clients given 4D weighing 0-3.9kg','Clients given 4D weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 0-3.9kg\n Clients given 4D weighing 0-3.9kg\n \n 2022-06-30 10:08:47 UTC\n \n 2023-07-27 09:27:03 UTC\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 endDate\n \n java.util.Date\n true\n \n \n 1455\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 \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 \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 (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 > 0 and _weight <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:08:47',4,'2023-07-27 11:27:03',4,0,NULL,NULL,NULL,'d998e2f6-840d-473b-b176-e0550de42412'),(1456,'Clients given 4D weighing 4-5.9kg','Clients given 4D weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 4-5.9kg\n Clients given 4D weighing 4-5.9kg\n \n 2022-06-30 10:13:16 UTC\n \n 2023-07-27 09:38: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 1456\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 \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 \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 (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 >= 4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:13:16',4,'2023-07-27 11:38:34',4,0,NULL,NULL,NULL,'6a8a13fc-28a2-4778-840f-e45fb90009b6'),(1457,'Clients given 4D weighing 6-9.9kg','Clients given 4D weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 6-9.9kg\n Clients given 4D weighing 6-9.9kg\n \n 2022-06-30 10:15:03 UTC\n \n 2023-07-27 09:39: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 1457\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 \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 \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 (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 >= 6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:15:03',4,'2023-07-27 11:39:10',4,0,NULL,NULL,NULL,'5d76364b-1150-4bd7-b456-7844b2f28312'),(1458,'Clients given 4J weighing 4-5.9kg','Clients given 4J weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 4-5.9kg\n Clients given 4J weighing 4-5.9kg\n \n 2022-06-30 10:15:44 UTC\n \n 2023-07-27 11:01: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 1458\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:15:44',4,'2023-07-27 13:01:23',4,0,NULL,NULL,NULL,'8a4200ea-3da7-406f-9961-272c3898fe6c'),(1459,'Clients given 4D weighing 10-13.9kg','Clients given 4D weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 10-13.9kg\n Clients given 4D weighing 10-13.9kg\n \n 2022-06-30 10:18:04 UTC\n \n 2023-07-27 09:28: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 1459\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 \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 \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 (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 >= 10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:18:04',4,'2023-07-27 11:28:41',4,0,NULL,NULL,NULL,'8a6e7ee5-2a61-4944-bfb4-bb47a5698f6c'),(1460,'Clients given 4D weighing 14-19.9kg','Clients given 4D weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 14-19.9kg\n Clients given 4D weighing 14-19.9kg\n \n 2022-06-30 10:19:54 UTC\n \n 2023-07-27 09:36: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 1460\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 \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 \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 (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 >= 14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:19:54',4,'2023-07-27 11:36:07',4,0,NULL,NULL,NULL,'45092d9a-31f7-4734-bad7-6afa4af47c8c'),(1461,'Clients given 4J weighing 6-9.9kg','Clients given 4J weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 6-9.9kg\n Clients given 4J weighing 6-9.9kg\n \n 2022-06-30 10:21:51 UTC\n \n 2023-07-27 11:01: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 1461\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:21:51',4,'2023-07-27 13:01:41',4,0,NULL,NULL,NULL,'5f5b772e-63e5-4b96-b211-629491f33c0d'),(1462,'Clients given 4D weighing 20-24.9kg','Clients given 4D weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 20-24.9kg\n Clients given 4D weighing 20-24.9kg\n \n 2022-06-30 10:22:05 UTC\n \n 2023-07-27 09: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 1462\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 \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 \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 (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','2022-06-30 12:22:05',4,'2023-07-27 11:36:30',4,0,NULL,NULL,NULL,'a0d8e3b8-722d-491c-bd0f-fa90956f51db'),(1463,'Clients given 4J weighing 10-13.9kg','Clients given 4J weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 10-13.9kg\n Clients given 4J weighing 10-13.9kg\n \n 2022-06-30 10:22:53 UTC\n \n 2023-07-27 10:59: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 1463\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:22:53',4,'2023-07-27 12:59:41',4,0,NULL,NULL,NULL,'790715b6-630c-4294-8577-6f4815e44797'),(1464,'Clients given 4J weighing 14-19.9kg','Clients given 4J weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 14-19.9kg\n Clients given 4J weighing 14-19.9kg\n \n 2022-06-30 10:24:03 UTC\n \n 2023-07-27 10:59: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 1464\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:24:03',4,'2023-07-27 12:59:55',4,0,NULL,NULL,NULL,'08528ef7-fb50-42e0-b520-afb3ecedbad2'),(1465,'Clients given 4D weighing 25-34.9kg','Clients given 4D weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 25-34.9kg\n Clients given 4D weighing 25-34.9kg\n \n 2022-06-30 10:24:49 UTC\n \n 2023-07-27 09:37: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 1465\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 \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 \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 (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 >= 25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:24:49',4,'2023-07-27 11:37:45',4,0,NULL,NULL,NULL,'527ab6b7-03a7-4ad5-86ae-2c494b0b3cb0'),(1466,'Clients given 4J weighing 20-24.9kg','Clients given 4J weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 20-24.9kg\n Clients given 4J weighing 20-24.9kg\n \n 2022-06-30 10:24:52 UTC\n \n 2023-07-27 11: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 1466\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 \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 \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 (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','2022-06-30 12:24:52',4,'2023-07-27 13:00:42',4,0,NULL,NULL,NULL,'65757623-b703-423a-a092-06e04ed87180'),(1467,'Clients given 4D weighing >= 35kg','Clients given 4D weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing >= 35kg\n Clients given 4D weighing >= 35kg\n \n 2022-06-30 10:27:51 UTC\n \n 2023-07-27 09:40: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 1467\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 \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 \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 (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 >= 35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:27:51',4,'2023-07-27 11:40:28',4,0,NULL,NULL,NULL,'242cded5-b463-489d-a941-901a590d1d47'),(1468,'Clients given 4J weighing 25-34.9kg','Clients given 4J weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 25-34.9kg\n Clients given 4J weighing 25-34.9kg\n \n 2022-06-30 10:28:09 UTC\n \n 2023-07-27 11:01: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 1468\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:28:09',4,'2023-07-27 13:01:04',4,0,NULL,NULL,NULL,'83bc989a-e2b7-4bed-a628-fc59a59c1ba6'),(1469,'Clients given 4J weighing >=35kg','Clients given 4J weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing >=35kg\n Clients given 4J weighing >=35kg\n \n 2022-06-30 10:28:53 UTC\n \n 2023-07-27 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 1469\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:28:53',4,'2023-07-27 12:58:41',4,0,NULL,NULL,NULL,'72f98838-eb15-4cb6-a914-0852726e5647'),(1470,'Clients given 4E weighing 0-3.9kg','Clients given 4E weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 0-3.9kg\n Clients given 4E weighing 0-3.9kg\n \n 2022-06-30 10:29:43 UTC\n \n 2023-07-27 10:22: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 1470\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:29:43',4,'2023-07-27 12:22:02',4,0,NULL,NULL,NULL,'0ab11624-0249-40a0-971b-e3e8bb23ea70'),(1471,'Clients given 4E weighing 4-5.9kg','Clients given 4E weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 4-5.9kg\n Clients given 4E weighing 4-5.9kg\n \n 2022-06-30 10:33:36 UTC\n \n 2023-07-27 10:26: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 1471\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:33:36',4,'2023-07-27 12:26:59',4,0,NULL,NULL,NULL,'8519fd1c-bd73-43d6-8c51-e76191131ca3'),(1472,'Clients given 4E weighing 6-9.9kg','Clients given 4E weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 6-9.9kg\n Clients given 4E weighing 6-9.9kg\n \n 2022-06-30 10:35:26 UTC\n \n 2023-07-27 10:27: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 1472\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:35:26',4,'2023-07-27 12:27:56',4,0,NULL,NULL,NULL,'c165720f-b024-49dc-8775-49de3830ea6f'),(1473,'Clients given 4E weighing 10-13.9kg','Clients given 4E weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 10-13.9kg\n Clients given 4E weighing 10-13.9kg\n \n 2022-06-30 10:36:35 UTC\n \n 2023-07-27 10:22: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 java.lang.String\n true\n \n \n 1473\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:36:35',4,'2023-07-27 12:22:52',4,0,NULL,NULL,NULL,'c14db25f-8596-4fae-ab12-430a740aa487'),(1474,'Clients given 4E weighing 14-19.9kg','Clients given 4E weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 14-19.9kg\n Clients given 4E weighing 14-19.9kg\n \n 2022-06-30 10:38:12 UTC\n \n 2023-07-27 10:24: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 1474\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:38:12',4,'2023-07-27 12:24:17',4,0,NULL,NULL,NULL,'bc5dc540-6696-47aa-a512-1cb7a78d7377'),(1475,'Clients given 4E weighing 20-24.9kg','Clients given 4E weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 20-24.9kg\n Clients given 4E weighing 20-24.9kg\n \n 2022-06-30 10:40:04 UTC\n \n 2023-07-27 10:25: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 1475\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 \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 \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 (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','2022-06-30 12:40:04',4,'2023-07-27 12:25:54',4,0,NULL,NULL,NULL,'221244d7-0042-432a-a711-d9cccd4358ab'),(1476,'Clients given 4E weighing 25-34.9kg','Clients given 4E weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 25-34.9kg\n Clients given 4E weighing 25-34.9kg\n \n 2022-06-30 10:41:40 UTC\n \n 2023-07-27 10: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 1476\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:41:40',4,'2023-07-27 12:26:28',4,0,NULL,NULL,NULL,'9490638d-1289-4114-bbbc-724006e38d93'),(1477,'Clients given 4E weighing >= 35kg','Clients given 4E weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing >= 35kg\n Clients given 4E weighing >= 35kg\n \n 2022-06-30 10:43:04 UTC\n \n 2023-07-27 10:21: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 1477\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:43:04',4,'2023-07-27 12:21:29',4,0,NULL,NULL,NULL,'2bf8b315-8095-4176-ab7c-34d32e5302bb'),(1478,'Clients given 4F weighing 0-3.9kg','Clients given 4F weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 0-3.9kg\n Clients given 4F weighing 0-3.9kg\n \n 2022-06-30 10:44:22 UTC\n \n 2023-07-27 10:41: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 1478\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:44:22',4,'2023-07-27 12:41:29',4,0,NULL,NULL,NULL,'42b80ebc-ab48-48ca-a4f4-a20229c3e624'),(1479,'Clients given 4H weighing 0-3.9kg','Clients given 4H weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 0-3.9kg\n Clients given 4H weighing 0-3.9kg\n \n 2022-06-30 10:44:56 UTC\n \n 2023-07-27 10:55: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 1479\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:44:56',4,'2023-07-27 12:55:00',4,0,NULL,NULL,NULL,'4d8d584e-acb2-4935-b2ba-b1b175d8f7d5'),(1480,'Clients given 4H weighing 4-5.9kg','Clients given 4H weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 4-5.9kg\n Clients given 4H weighing 4-5.9kg\n \n 2022-06-30 10:46:13 UTC\n \n 2023-07-27 10:56: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 1480\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:46:13',4,'2023-07-27 12:56:53',4,0,NULL,NULL,NULL,'26f845a2-246d-468b-817a-9c60bdd078b9'),(1481,'Clients given 4F weighing 4-5.9kg','Clients given 4F weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 4-5.9kg\n Clients given 4F weighing 4-5.9kg\n \n 2022-06-30 10:46:29 UTC\n \n 2023-07-27 10:43: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 1481\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:46:29',4,'2023-07-27 12:43:41',4,0,NULL,NULL,NULL,'72862b43-6e4e-4a10-822f-ac5648433215'),(1482,'Clients given 4H weighing 6-9.9kg','Clients given 4H weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 6-9.9kg\n Clients given 4H weighing 6-9.9kg\n \n 2022-06-30 10:46:57 UTC\n \n 2023-07-27 10:57: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 1482\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:46:57',4,'2023-07-27 12:57:16',4,0,NULL,NULL,NULL,'01c48121-50df-46cb-8a3b-35623d584ebf'),(1483,'Clients given 4H weighing 10-13.9kg','Clients given 4H weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 10-13.9kg\n Clients given 4H weighing 10-13.9kg\n \n 2022-06-30 10:47:36 UTC\n \n 2023-07-27 10:55: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 1483\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:47:36',4,'2023-07-27 12:55:36',4,0,NULL,NULL,NULL,'d02359fe-619b-4a9c-871b-ae3aa3a98aa2'),(1484,'Clients given 4F weighing 6-9.9kg','Clients given 4F weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 6-9.9kg\n Clients given 4F weighing 6-9.9kg\n \n 2022-06-30 10:47:39 UTC\n \n 2023-07-27 10:44: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 1484\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:47:39',4,'2023-07-27 12:44:02',4,0,NULL,NULL,NULL,'b67ded87-6d0d-4d6a-8d86-01fffedfca86'),(1485,'Clients given 4F weighing 10-13.9kg','Clients given 4F weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 10-13.9kg\n Clients given 4F weighing 10-13.9kg\n \n 2022-06-30 10:48:47 UTC\n \n 2023-07-27 10:41: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 1485\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:48:47',4,'2023-07-27 12:41:53',4,0,NULL,NULL,NULL,'9ff30aca-0d8d-4fca-a3a9-13c0f28c48ac'),(1486,'Clients given 4H weighing 14-19.9kg','Clients given 4H weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 14-19.9kg\n Clients given 4H weighing 14-19.9kg\n \n 2022-06-30 10:48:50 UTC\n \n 2023-07-27 10:55: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 1486\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:48:50',4,'2023-07-27 12:55:55',4,0,NULL,NULL,NULL,'4477b341-8fb3-4d94-bc1a-cec68c45d5e8'),(1487,'Clients given 4F weighing 14-19.9kg','Clients given 4F weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 14-19.9kg\n Clients given 4F weighing 14-19.9kg\n \n 2022-06-30 10:49:43 UTC\n \n 2023-07-27 10:42: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 1487\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:49:43',4,'2023-07-27 12:42:09',4,0,NULL,NULL,NULL,'bc68c0e3-f9af-458a-9c48-e498e27e55cf'),(1488,'Clients given 4H weighing 20-24.9kg','Clients given 4H weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 20-24.9kg\n Clients given 4H weighing 20-24.9kg\n \n 2022-06-30 10:49:44 UTC\n \n 2023-07-27 10:56: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 1488\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 \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 \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 (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','2022-06-30 12:49:44',4,'2023-07-27 12:56:17',4,0,NULL,NULL,NULL,'db7df0b0-048e-4292-8047-aede481f516a'),(1489,'Clients given 4H weighing 25-34.9kg','Clients given 4H weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 25-34.9kg\n Clients given 4H weighing 25-34.9kg\n \n 2022-06-30 10:50:30 UTC\n \n 2023-07-27 10:56: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 1489\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:50:30',4,'2023-07-27 12:56:36',4,0,NULL,NULL,NULL,'8a0ffc3a-6f13-41d4-9012-80f7df387328'),(1490,'Clients given 4F weighing 20-24.9kg','Clients given 4F weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 20-24.9kg\n Clients given 4F weighing 20-24.9kg\n \n 2022-06-30 10:50:41 UTC\n \n 2023-07-27 10:42: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 1490\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 \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 \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 (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','2022-06-30 12:50:41',4,'2023-07-27 12:42:33',4,0,NULL,NULL,NULL,'acf07216-1652-4e83-9d65-6823c59981a8'),(1491,'Clients given 4H weighing >=35kg','Clients given 4H weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing >=35kg\n Clients given 4H weighing >=35kg\n \n 2022-06-30 10:51:17 UTC\n \n 2023-07-27 10:54: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 1491\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:51:17',4,'2023-07-27 12:54:12',4,0,NULL,NULL,NULL,'831a76ea-3a0d-4c8c-b68f-fcb26f67f6d8'),(1492,'Clients given 4F weighing 25-34.9kg','Clients given 4F weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 25-34.9kg\n Clients given 4F weighing 25-34.9kg\n \n 2022-06-30 10:51:46 UTC\n \n 2023-07-27 10:43: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 1492\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:51:46',4,'2023-07-27 12:43:13',4,0,NULL,NULL,NULL,'3da33639-d791-4633-8e15-b41313cb55f1'),(1493,'Clients given 4F weighing >= 35kg','Clients given 4F weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing >= 35kg\n Clients given 4F weighing >= 35kg\n \n 2022-06-30 10:53:56 UTC\n \n 2023-07-27 10:40: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 1493\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:53:56',4,'2023-07-27 12:40:58',4,0,NULL,NULL,NULL,'c7599281-45dd-4b73-8ab0-ea8e524b98d1'),(1494,'Clients given 4G weighing 0-3.9kg','Clients given 4G weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 0-3.9kg\n Clients given 4G weighing 0-3.9kg\n \n 2022-06-30 10:54:05 UTC\n \n 2023-07-27 10:46: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 1494\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:54:05',4,'2023-07-27 12:46:39',4,0,NULL,NULL,NULL,'2475b103-3fa8-4b29-bb87-fab00aa27257'),(1495,'Clients given 4G weighing 4-5.9kg','Clients given 4G weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 4-5.9kg\n Clients given 4G weighing 4-5.9kg\n \n 2022-06-30 10:55:47 UTC\n \n 2023-07-27 10:48: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 1495\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:55:47',4,'2023-07-27 12:48:33',4,0,NULL,NULL,NULL,'b7fef4f2-1d0c-4942-88e3-45c9535ef4bc'),(1496,'Clients given 4G weighing 6-9.9kg','Clients given 4G weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 6-9.9kg\n Clients given 4G weighing 6-9.9kg\n \n 2022-06-30 10:56:50 UTC\n \n 2023-07-27 10:48: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 1496\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:56:50',4,'2023-07-27 12:48:51',4,0,NULL,NULL,NULL,'2539084a-3b56-4fd2-b7b7-1d75b7403e4c'),(1497,'Clients given 4G weighing 10-13.9kg','Clients given 4G weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 10-13.9kg\n Clients given 4G weighing 10-13.9kg\n \n 2022-06-30 10:57:46 UTC\n \n 2023-07-27 10:47: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 1497\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:57:46',4,'2023-07-27 12:47:08',4,0,NULL,NULL,NULL,'f7e13045-87fd-45c5-9e4c-818fbcb84888'),(1498,'Clients given 5A weighing 0-3.9kg','Clients given 5A weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 0-3.9kg\n Clients given 5A weighing 0-3.9kg\n \n 2022-06-30 10:58:03 UTC\n \n 2023-08-15 09:30: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 1498\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 \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 \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 (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>=0 and _weight <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:58:03',4,'2023-08-15 11:30:27',4,0,NULL,NULL,NULL,'87a82695-8e84-4f45-9b37-6fcfbdd68b9b'),(1499,'Clients given 4G weighing 14-19.9kg','Clients given 4G weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 14-19.9kg\n Clients given 4G weighing 14-19.9kg\n \n 2022-06-30 10:58:40 UTC\n \n 2023-07-27 10:47: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 1499\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:58:40',4,'2023-07-27 12:47:25',4,0,NULL,NULL,NULL,'91726710-94cf-4118-9c47-766cb5f11ae8'),(1500,'Clients given 4G weighing 20-24.9kg','Clients given 4G weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 20-24.9kg\n Clients given 4G weighing 20-24.9kg\n \n 2022-06-30 10:59:29 UTC\n \n 2023-07-27 10:47: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 1500\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 \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 \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 (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','2022-06-30 12:59:29',4,'2023-07-27 12:47:44',4,0,NULL,NULL,NULL,'e1070366-40ee-4f52-ae16-34a5de911a65'),(1501,'Clients given 4G weighing 25-34.9kg','Clients given 4G weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 25-34.9kg\n Clients given 4G weighing 25-34.9kg\n \n 2022-06-30 11:00:09 UTC\n \n 2023-07-27 10:48: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 1501\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:00:09',4,'2023-07-27 12:48:09',4,0,NULL,NULL,NULL,'d95d19d8-05d8-49d2-8b48-e0e179a7d99f'),(1502,'Clients given 5A weighing 4-5.9kg','Clients given 5A weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 4-5.9kg\n Clients given 5A weighing 4-5.9kg\n \n 2022-06-30 11:00:22 UTC\n \n 2023-08-15 10:10: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 1502\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:00:22',4,'2023-08-15 12:10:02',4,0,NULL,NULL,NULL,'5b216507-efb0-46a6-a948-08f4bc7a2bf2'),(1503,'Clients given 4G weighing >=35kg','Clients given 4G weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing >=35kg\n Clients given 4G weighing >=35kg\n \n 2022-06-30 11:00:59 UTC\n \n 2023-07-27 10:46: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 1503\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:00:59',4,'2023-07-27 12:46:14',4,0,NULL,NULL,NULL,'0aa0cdb4-feed-4504-ad23-50fdfbb94347'),(1504,'Clients given 5A weighing 6-9.9kg','Clients given 5A weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 6-9.9kg\n Clients given 5A weighing 6-9.9kg\n \n 2022-06-30 11:01:39 UTC\n \n 2022-06-30 11:02: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 1504\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:01:39',4,'2022-06-30 13:02:04',4,0,NULL,NULL,NULL,'8c1a3939-af3e-4859-bc97-cfb2a9d2e712'),(1505,'Clients given 5A weighing 10-13.9kg','Clients given 5A weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 10-13.9kg\n Clients given 5A weighing 10-13.9kg\n \n 2022-06-30 11:02:41 UTC\n \n 2023-08-15 09:38: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 1505\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:02:41',4,'2023-08-15 11:38:33',4,0,NULL,NULL,NULL,'3f90eaa0-49f7-4c6b-8ef4-9d75b1e83139'),(1506,'Clients given 5A weighing 14-19.9kg','Clients given 5A weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 14-19.9kg\n Clients given 5A weighing 14-19.9kg\n \n 2022-06-30 11:04:00 UTC\n \n 2023-08-15 09:44: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 1506\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:04:00',4,'2023-08-15 11:44:19',4,0,NULL,NULL,NULL,'f1b1f749-bfcc-4a13-b348-64c59866cc59'),(1507,'Clients given 5A weighing 20-24.9kg','Clients given 5A weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 20-24.9kg\n Clients given 5A weighing 20-24.9kg\n \n 2022-06-30 11:04:47 UTC\n \n 2023-08-15 09:46: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 1507\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 \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 \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 (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','2022-06-30 13:04:47',4,'2023-08-15 11:46:25',4,0,NULL,NULL,NULL,'abad239c-e77e-4577-9ce7-dec2f8fec968'),(1508,'Clients given 5H weighing 0-3.9kg','Clients given 5H weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 0-3.9kg\n Clients given 5H weighing 0-3.9kg\n \n 2022-06-30 11:05:16 UTC\n \n 2022-06-30 11:05: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 1508\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 \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 \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 (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 > 0 and _weight <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:05:16',4,'2022-06-30 13:05:45',4,0,NULL,NULL,NULL,'6197805b-306c-4d08-8146-fa728c86cad0'),(1509,'Clients given 5A weighing 25-34.9kg','Clients given 5A weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 25-34.9kg\n Clients given 5A weighing 25-34.9kg\n \n 2022-06-30 11:05:57 UTC\n \n 2023-08-15 09:48: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 1509\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:05:57',4,'2023-08-15 11:48:51',4,0,NULL,NULL,NULL,'56bc1e3d-3e39-4a2a-be29-f923f3403a9f'),(1510,'Clients given 5H weighing 4-5.9kg','Clients given 5H weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 4-5.9kg\n Clients given 5H weighing 4-5.9kg\n \n 2022-06-30 11:06:12 UTC\n \n 2022-06-30 11:06: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 1510\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 \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 \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 (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 >= 4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:06:12',4,'2022-06-30 13:06:36',4,0,NULL,NULL,NULL,'f46b6d84-55a7-4fd0-af6d-da58bdfdadbc'),(1511,'Clients given 5A weighing >= 35kg','Clients given 5A weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing >= 35kg\n Clients given 5A weighing >= 35kg\n \n 2022-06-30 11:07:03 UTC\n \n 2022-06-30 11:07: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 1511\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:07:03',4,'2022-06-30 13:07:39',4,0,NULL,NULL,NULL,'7313b979-6116-4b8c-8d45-159dce135628'),(1512,'Clients given 5H weighing 6-9.9kg','Clients given 5H weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 6-9.9kg\n Clients given 5H weighing 6-9.9kg\n \n 2022-06-30 11:07:30 UTC\n \n 2022-06-30 11: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 1512\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 \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 \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 (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 >= 6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:07:30',4,'2022-06-30 13:07:53',4,0,NULL,NULL,NULL,'b302e353-da5b-495a-92bf-ac972aa7f94e'),(1513,'Clients given 5B weighing 0-3.9kg','Clients given 5B weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 0-3.9kg\n Clients given 5B weighing 0-3.9kg\n \n 2022-06-30 11:08:51 UTC\n \n 2023-08-15 10:23: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 1513\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 \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 \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 (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>=0 and _weight <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:08:51',4,'2023-08-15 12:23:59',4,0,NULL,NULL,NULL,'01fe5f00-9f8a-44c2-ba40-160f9d05d725'),(1514,'Clients given 5H weighing 10-13.9kg','Clients given 5H weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 10-13.9kg\n Clients given 5H weighing 10-13.9kg\n \n 2022-06-30 11:08:53 UTC\n \n 2022-06-30 11:09: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 1514\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 \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 \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 (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 >= 10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:08:53',4,'2022-06-30 13:09:15',4,0,NULL,NULL,NULL,'fb13cd05-3a8a-4559-9bf2-8f2f4e2df601'),(1515,'Clients given 5H weighing 14-19.9kg','Clients given 5H weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 14-19.9kg\n Clients given 5H weighing 14-19.9kg\n \n 2022-06-30 11:09:36 UTC\n \n 2022-06-30 11:09: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 1515\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 \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 \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 (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 >= 14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:09:36',4,'2022-06-30 13:09:52',4,0,NULL,NULL,NULL,'b99e2ade-ec65-4904-a6ca-e333b39322b6'),(1516,'Clients given 5H weighing 20-24.9kg','Clients given 5H weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 20-24.9kg\n Clients given 5H weighing 20-24.9kg\n \n 2022-06-30 11:10:25 UTC\n \n 2022-06-30 11:10: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 1516\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 \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 \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 (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','2022-06-30 13:10:25',4,'2022-06-30 13:10:43',4,0,NULL,NULL,NULL,'66408707-e4ad-4d2b-973c-77cd0220240c'),(1517,'Clients given 5B weighing 4-5.9kg','Clients given 5B weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 4-5.9kg\n Clients given 5B weighing 4-5.9kg\n \n 2022-06-30 11:10:36 UTC\n \n 2023-08-15 10:49: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 1517\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:10:36',4,'2023-08-15 12:49:11',4,0,NULL,NULL,NULL,'ad0df8d9-d10d-4991-aa03-f7a96d902f69'),(1518,'Clients given 5H weighing 25-34.9kg','Clients given 5H weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 25-34.9kg\n Clients given 5H weighing 25-34.9kg\n \n 2022-06-30 11:11:12 UTC\n \n 2022-06-30 11: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 1518\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 \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 \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 (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 >= 25 and _weight <= 34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:11:12',4,'2022-06-30 13:11:36',4,0,NULL,NULL,NULL,'67f0bd48-1cbf-4d6b-b037-1789f1b9f734'),(1519,'Clients given 5B weighing 6-9.9kg','Clients given 5B weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 6-9.9kg\n Clients given 5B weighing 6-9.9kg\n \n 2022-06-30 11:11:51 UTC\n \n 2023-08-15 10: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 1519\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:11:51',4,'2023-08-15 12:50:59',4,0,NULL,NULL,NULL,'fcd13eef-bda1-46af-993f-ad29378c624a'),(1520,'Clients given 5H weighing >=35kg','Clients given 5H weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing >=35kg\n Clients given 5H weighing >=35kg\n \n 2022-06-30 11:12:13 UTC\n \n 2022-06-30 11:12: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 1520\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 \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 \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 (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 >= 35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:12:13',4,'2022-06-30 13:12:39',4,0,NULL,NULL,NULL,'837029cf-0489-433f-b1f4-93207eb1bae5'),(1521,'Clients given 5B weighing 10-13.9kg','Clients given 5B weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 10-13.9kg\n Clients given 5B weighing 10-13.9kg\n \n 2022-06-30 11:13:00 UTC\n \n 2023-08-15 10:36: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 1521\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:13:00',4,'2023-08-15 12:36:42',4,0,NULL,NULL,NULL,'f90822d7-8137-44bf-9b66-0022b61e1ece'),(1522,'Clients given 5B weighing 14-19.9kg','Clients given 5B weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 14-19.9kg\n Clients given 5B weighing 14-19.9kg\n \n 2022-06-30 11:13:55 UTC\n \n 2023-08-15 10:38: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 1522\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:13:55',4,'2023-08-15 12:38:36',4,0,NULL,NULL,NULL,'247d8f89-0b72-4010-9328-a87600bd22d9'),(1523,'Clients given 5B weighing 20-24.9kg','Clients given 5B weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 20-24.9kg\n Clients given 5B weighing 20-24.9kg\n \n 2022-06-30 11:14:57 UTC\n \n 2023-08-15 10:43: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 1523\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 \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 \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 (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','2022-06-30 13:14:57',4,'2023-08-15 12:43:27',4,0,NULL,NULL,NULL,'b9f0c6b6-a9f7-4ec3-9563-92a43def2068'),(1524,'Clients given 5G weighing 0-3.9kg','Clients given 5G weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 0-3.9kg\n Clients given 5G weighing 0-3.9kg\n \n 2022-06-30 11:15:26 UTC\n \n 2023-08-15 14:15: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 1524\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 \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 \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 (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 > 0 and _weight <= 3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:15:26',4,'2023-08-15 16:15:28',4,0,NULL,NULL,NULL,'d6899230-0f9b-4682-8822-478bfa1ad941'),(1525,'Clients given 5G weighing 4-5.9kg','Clients given 5G weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 4-5.9kg\n Clients given 5G weighing 4-5.9kg\n \n 2022-06-30 11:16:09 UTC\n \n 2023-08-15 14: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 1525\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 \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 \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 (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 >= 4 and _weight <= 5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:16:09',4,'2023-08-15 16:20:31',4,0,NULL,NULL,NULL,'e0607707-f27c-434f-a5cd-44ed04531b3d'),(1526,'Clients given 5B weighing 25-34.9kg','Clients given 5B weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 25-34.9kg\n Clients given 5B weighing 25-34.9kg\n \n 2022-06-30 11:16:20 UTC\n \n 2023-08-15 10:46: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 1526\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:16:20',4,'2023-08-15 12:46:41',4,0,NULL,NULL,NULL,'bd44e473-7f7a-4848-beb6-414f3c87ada1'),(1527,'Clients given 5G weighing 6-9.9kg','Clients given 5G weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 6-9.9kg\n Clients given 5G weighing 6-9.9kg\n \n 2022-06-30 11:17:00 UTC\n \n 2023-08-15 14:21: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 1527\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 \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 \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 (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 >= 6 and _weight <= 9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:17:00',4,'2023-08-15 16:21:24',4,0,NULL,NULL,NULL,'2fa35676-ccce-4bde-a76f-65b9de55fd54'),(1528,'Clients given 5B weighing >= 35kg','Clients given 5B weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing >= 35kg\n Clients given 5B weighing >= 35kg\n \n 2022-06-30 11:17:28 UTC\n \n 2023-08-15 10:21: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 1528\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:17:28',4,'2023-08-15 12:21:09',4,0,NULL,NULL,NULL,'25a796fe-9437-4e38-9c95-6ef6bb295e8e'),(1529,'Clients given 5G weighing 10-13.9kg','Clients given 5G weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 10-13.9kg\n Clients given 5G weighing 10-13.9kg\n \n 2022-06-30 11:18:10 UTC\n \n 2023-08-15 14: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 1529\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 \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 \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 (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 >= 10 and _weight <= 13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:18:10',4,'2023-08-15 16:16:57',4,0,NULL,NULL,NULL,'00ae6c3c-d1c6-44b8-ae77-0b0dadd15e1f'),(1530,'Clients given 5C weighing 0-3.9kg','Clients given 5C weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 0-3.9kg\n Clients given 5C weighing 0-3.9kg\n \n 2022-06-30 11:19:00 UTC\n \n 2023-08-15 10:58: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 1530\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 \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 \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 (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>=0 and _weight <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:19:00',4,'2023-08-15 12:58:29',4,0,NULL,NULL,NULL,'1e058b14-9ac4-4412-96ab-33fd04c575b0'),(1531,'Clients given 5G weighing 14-19.9kg','Clients given 5G weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 14-19.9kg\n Clients given 5G weighing 14-19.9kg\n \n 2022-06-30 11:19:16 UTC\n \n 2023-08-15 14:18: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 1531\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 \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 \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 (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 >= 14 and _weight <= 19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:19:16',4,'2023-08-15 16:18:04',4,0,NULL,NULL,NULL,'2d4f2764-5ad4-4259-88bc-d6cfe29e5365'),(1532,'Clients given 5G weighing 20-24.9kg','Clients given 5G weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 20-24.9kg\n Clients given 5G weighing 20-24.9kg\n \n 2022-06-30 11:19:50 UTC\n \n 2023-08-15 14:18: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 1532\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 \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 \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 (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','2022-06-30 13:19:50',4,'2023-08-15 16:18:49',4,0,NULL,NULL,NULL,'5869ce40-ff99-4614-b3f5-e058345f91a8'),(1533,'Clients given 5G weighing 25 -34.9kg','Clients given 5G weighing 25 -34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 25 -34.9kg\n Clients given 5G weighing 25 -34.9kg\n \n 2022-06-30 11:20:43 UTC\n \n 2023-08-15 14:19: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 1533\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 \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 \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 (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 >= 25 and _weight <= 34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:20:43',4,'2023-08-15 16:19:37',4,0,NULL,NULL,NULL,'3134cfcd-283c-43a2-bb15-8ae6356ebbdd'),(1534,'Clients given 5C weighing 4-5.9kg','Clients given 5C weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 4-5.9kg\n Clients given 5C weighing 4-5.9kg\n \n 2022-06-30 11:21:08 UTC\n \n 2023-08-15 11: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 1534\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:21:08',4,'2023-08-15 13:12:06',4,0,NULL,NULL,NULL,'b6a6e9f5-36ec-414e-95ec-b4a4bb1e7f77'),(1535,'Clients given 5G weighing >=35kg','Clients given 5G weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing >=35kg\n Clients given 5G weighing >=35kg\n \n 2022-06-30 11:21:23 UTC\n \n 2023-08-15 14:14: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 1535\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 \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 \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 (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 >= 35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:21:23',4,'2023-08-15 16:14:25',4,0,NULL,NULL,NULL,'cb219c31-fab1-4f82-a202-48a4a8744a6e'),(1536,'Clients given 5C weighing 6-9.9kg','Clients given 5C weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 6-9.9kg\n Clients given 5C weighing 6-9.9kg\n \n 2022-06-30 11:22:17 UTC\n \n 2023-08-15 11:16: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 1536\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:22:17',4,'2023-08-15 13:16:22',4,0,NULL,NULL,NULL,'e96a3e05-ee48-46f8-ad52-7ea11c785404'),(1537,'Clients given 5F weighing 0-3.9kg','Clients given 5F weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 0-3.9kg\n Clients given 5F weighing 0-3.9kg\n \n 2022-06-30 11:22:53 UTC\n \n 2023-08-15 13:52: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 1537\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 \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 \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 > 0 and _weight <= 3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:22:53',4,'2023-08-15 15:52:56',4,0,NULL,NULL,NULL,'3ed934cc-c2f7-4f9c-ab10-1794412389f1'),(1538,'Clients given 5C weighing 10-13.9kg','Clients given 5C weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 10-13.9kg\n Clients given 5C weighing 10-13.9kg\n \n 2022-06-30 11:23:09 UTC\n \n 2023-08-15 11:00: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 1538\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:23:09',4,'2023-08-15 13:00:14',4,0,NULL,NULL,NULL,'35aa87a9-9aec-42c6-a80d-1f71d2be1ef8'),(1539,'Clients given 5C weighing 14-19.9kg','Clients given 5C weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 14-19.9kg\n Clients given 5C weighing 14-19.9kg\n \n 2022-06-30 11:23:56 UTC\n \n 2023-08-15 11:03: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 1539\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:23:56',4,'2023-08-15 13:03:40',4,0,NULL,NULL,NULL,'8827cdb6-b0b0-4dad-84d7-d06aae03ac3b'),(1540,'Clients given 5C weighing 20-24.9kg','Clients given 5C weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 20-24.9kg\n Clients given 5C weighing 20-24.9kg\n \n 2022-06-30 11:24:56 UTC\n \n 2023-08-15 11:06: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 1540\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 \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 \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 (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','2022-06-30 13:24:56',4,'2023-08-15 13:06:21',4,0,NULL,NULL,NULL,'7cc30e9c-763c-454b-b961-d19c47d2da6a'),(1541,'Clients given 5F weighing 4-5.9kg','Clients given 5F weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 4-5.9kg\n Clients given 5F weighing 4-5.9kg\n \n 2022-06-30 11:24:57 UTC\n \n 2022-06-30 11:26: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 1541\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 \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 \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 >= 4 and _weight <= 5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:24:57',4,'2022-06-30 13:26:23',4,0,NULL,NULL,NULL,'86aec40b-a4e3-49f5-8c61-1b4395bddd75'),(1542,'Clients given 5F weighing 6-9.9kg','Clients given 5F weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 6-9.9kg\n Clients given 5F weighing 6-9.9kg\n \n 2022-06-30 11:25:26 UTC\n \n 2023-08-15 14:09: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 1542\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 \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 \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 >= 6 and _weight <= 9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:25:26',4,'2023-08-15 16:09:20',4,0,NULL,NULL,NULL,'74ddbe48-ab4a-40e2-be97-c0ecfca4ec3d'),(1543,'Clients given 5C weighing 25-34.9kg','Clients given 5C weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 25-34.9kg\n Clients given 5C weighing 25-34.9kg\n \n 2022-06-30 11:26:03 UTC\n \n 2022-06-30 11:26: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 1543\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:26:03',4,'2022-06-30 13:26:35',4,0,NULL,NULL,NULL,'62831d13-bff3-4d96-b097-03c7f656489c'),(1544,'Clients given 5F weighing 10-13.9kg','Clients given 5F weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 10-13.9kg\n Clients given 5F weighing 10-13.9kg\n \n 2022-06-30 11:26:51 UTC\n \n 2023-08-15 13:54: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 1544\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 \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 \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 >= 10 and _weight <= 13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:26:51',4,'2023-08-15 15:54:54',4,0,NULL,NULL,NULL,'32b14f2b-ab48-4905-a130-7cc98fadc7a3'),(1545,'Clients given 5C weighing >= 35kg','Clients given 5C weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing >= 35kg\n Clients given 5C weighing >= 35kg\n \n 2022-06-30 11:27:06 UTC\n \n 2023-08-15 10:56: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 1545\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:27:06',4,'2023-08-15 12:56:19',4,0,NULL,NULL,NULL,'2253da71-2fae-4683-87c0-4e876e27b5d9'); -INSERT INTO `serialized_object` VALUES (1546,'Clients given 5F weighing 14-19.9kg','Clients given 5F weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 14-19.9kg\n Clients given 5F weighing 14-19.9kg\n \n 2022-06-30 11:27:37 UTC\n \n 2023-08-15 13:58: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 1546\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 \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 \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 >= 14 and _weight <= 19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:27:37',4,'2023-08-15 15:58:33',4,0,NULL,NULL,NULL,'ce94925c-9501-475d-8ab6-9a34881d6c9a'),(1547,'Clients given 5F weighing 20-24.9kg','Clients given 5F weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 20-24.9kg\n Clients given 5F weighing 20-24.9kg\n \n 2022-06-30 11:28:13 UTC\n \n 2023-08-15 14:00: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 1547\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 \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 \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','2022-06-30 13:28:13',4,'2023-08-15 16:00:55',4,0,NULL,NULL,NULL,'4e2fdf19-88d3-404b-8467-adbaba647c6c'),(1548,'Clients given 5D weighing 0-3.9kg','Clients given 5D weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 0-3.9kg\n Clients given 5D weighing 0-3.9kg\n \n 2022-06-30 11:28:24 UTC\n \n 2023-08-15 11:28: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 1548\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 \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 \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 (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>=0 and _weight <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:28:24',4,'2023-08-15 13:28:55',4,0,NULL,NULL,NULL,'9b7dc1a8-9c16-4ece-bf35-c13c45e27fd9'),(1549,'Clients given 5F weighing 25-34.9kg','Clients given 5F weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 25-34.9kg\n Clients given 5F weighing 25-34.9kg\n \n 2022-06-30 11:28:59 UTC\n \n 2023-08-15 14:02: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 1549\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 \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 \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 >= 25 and _weight <= 34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:28:59',4,'2023-08-15 16:02:41',4,0,NULL,NULL,NULL,'8a336065-e783-4b0b-bfba-d49c0507171c'),(1550,'Clients given 5D weighing 4-5.9kg','Clients given 5D weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 4-5.9kg\n Clients given 5D weighing 4-5.9kg\n \n 2022-06-30 11:29:51 UTC\n \n 2023-08-15 12:02: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 1550\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:29:51',4,'2023-08-15 14:02:22',4,0,NULL,NULL,NULL,'19fcd7c2-7d0e-4f89-8893-b7e56a90f565'),(1551,'Clients given 5F weighing >=35kg','Clients given 5F weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing >=35kg\n Clients given 5F weighing >=35kg\n \n 2022-06-30 11:30:09 UTC\n \n 2023-08-15 13:45: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 1551\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 \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 \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 >= 35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:30:09',4,'2023-08-15 15:45:47',4,0,NULL,NULL,NULL,'8d926451-29fe-44cb-9898-a0aed10c3786'),(1552,'Clients given 5D weighing 6-9.9kg','Clients given 5D weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 6-9.9kg\n Clients given 5D weighing 6-9.9kg\n \n 2022-06-30 11:30:53 UTC\n \n 2023-08-15 12:03: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 1552\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:30:53',4,'2023-08-15 14:03:43',4,0,NULL,NULL,NULL,'c4e2b4a6-62d3-4828-9088-05f88efd29d0'),(1553,'Clients given 5D weighing 10-13.9kg','Clients given 5D weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 10-13.9kg\n Clients given 5D weighing 10-13.9kg\n \n 2022-06-30 11:32:07 UTC\n \n 2023-08-15 11:52: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 1553\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:32:07',4,'2023-08-15 13:52:13',4,0,NULL,NULL,NULL,'af887c72-8ee7-4273-abe0-8755f691eeb7'),(1554,'Clients given 5E weighing 0-3.9kg','Clients given 5E weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 0-3.9kg\n Clients given 5E weighing 0-3.9kg\n \n 2022-06-30 11:33:14 UTC\n \n 2023-08-15 12:11: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 1554\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 \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 \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 (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 >= 0 and _weight <= 3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:33:14',4,'2023-08-15 14:11:02',4,0,NULL,NULL,NULL,'e79351a3-8b87-48de-879e-7f531c97ae16'),(1555,'Clients given 5D weighing 14-19.9kg','Clients given 5D weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 14-19.9kg\n Clients given 5D weighing 14-19.9kg\n \n 2022-06-30 11:33:21 UTC\n \n 2023-08-15 11:55: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 1555\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:33:21',4,'2023-08-15 13:55:11',4,0,NULL,NULL,NULL,'412170be-ff0c-4690-bc21-2fe362faafb1'),(1556,'Clients given 5E weighing 4-5.9kg','Clients given 5E weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 4-5.9kg\n Clients given 5E weighing 4-5.9kg\n \n 2022-06-30 11:34:03 UTC\n \n 2023-08-15 12:22: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 1556\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 \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 \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 (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 >= 4 and _weight <= 5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:34:03',4,'2023-08-15 14:22:56',4,0,NULL,NULL,NULL,'a6067fc6-8c70-4691-aa23-3e5a7973d4e4'),(1557,'Clients given 5D weighing 20-24.9kg','Clients given 5D weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 20-24.9kg\n Clients given 5D weighing 20-24.9kg\n \n 2022-06-30 11:34:31 UTC\n \n 2023-08-15 11:57: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 1557\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 \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 \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 (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','2022-06-30 13:34:31',4,'2023-08-15 13:57:06',4,0,NULL,NULL,NULL,'b12b32c4-ae91-44c1-bb7a-f2a4f0f74dcc'),(1558,'Clients given 5E weighing 6-9.9kg','Clients given 5E weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 6-9.9kg\n Clients given 5E weighing 6-9.9kg\n \n 2022-06-30 11:34:43 UTC\n \n 2023-08-15 12: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 1558\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 \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 \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 (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 >= 6 and _weight <= 9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:34:43',4,'2023-08-15 14:23:53',4,0,NULL,NULL,NULL,'ddbb6383-120a-4cfc-b376-eb9ec22e891b'),(1559,'Clients given 5E weighing 10-13.9kg','Clients given 5E weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 10-13.9kg\n Clients given 5E weighing 10-13.9kg\n \n 2022-06-30 11:35:22 UTC\n \n 2023-08-15 12:13: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 1559\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 \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 \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 (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 >= 10 and _weight <= 13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:35:22',4,'2023-08-15 14:13:26',4,0,NULL,NULL,NULL,'9334b5ec-d46f-465b-91f5-aba7e4f590a0'),(1560,'Clients given 5D weighing 25-34.9kg','Clients given 5D weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 25-34.9kg\n Clients given 5D weighing 25-34.9kg\n \n 2022-06-30 11:35:31 UTC\n \n 2023-08-15 11:59: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 1560\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:35:31',4,'2023-08-15 13:59:41',4,0,NULL,NULL,NULL,'88ff4abe-3367-4de0-be20-eaa6991568ce'),(1561,'Clients given 5E weighing 14-19.9kg','Clients given 5E weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 14-19.9kg\n Clients given 5E weighing 14-19.9kg\n \n 2022-06-30 11:36:01 UTC\n \n 2023-08-15 12:14: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 1561\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 \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 \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 (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 >= 14 and _weight <= 19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:36:01',4,'2023-08-15 14:14:47',4,0,NULL,NULL,NULL,'1514aaa6-288c-423b-96e6-ae5ee9074647'),(1562,'Clients given 5E weighing 20-24.9kg','Clients given 5E weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 20-24.9kg\n Clients given 5E weighing 20-24.9kg\n \n 2022-06-30 11:36:43 UTC\n \n 2023-08-15 12:20: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 1562\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 \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 \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 (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','2022-06-30 13:36:43',4,'2023-08-15 14:20:37',4,0,NULL,NULL,NULL,'28e98d97-dc6d-412f-89cb-3f19cd4d38b9'),(1563,'Clients given 5D weighing >= 35kg','Clients given 5D weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing >= 35kg\n Clients given 5D weighing >= 35kg\n \n 2022-06-30 11:36:48 UTC\n \n 2023-08-15 11:23: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 1563\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:36:48',4,'2023-08-15 13:23:11',4,0,NULL,NULL,NULL,'b4d8909f-2edb-4730-bf71-446d2fd8867c'),(1564,'Clients given 5E weighing 25-34.9kg','Clients given 5E weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 25-34.9kg\n Clients given 5E weighing 25-34.9kg\n \n 2022-06-30 11:37:59 UTC\n \n 2023-08-15 12:21: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 1564\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 \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 \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 (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 >= 25 and _weight <= 34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:37:59',4,'2023-08-15 14:21:55',4,0,NULL,NULL,NULL,'decbe846-1d21-400e-93c7-d535d80c75c2'),(1565,'Clients given 6A weighing 0-3.9kg','Clients given 6A weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 0-3.9kg\n Clients given 6A weighing 0-3.9kg\n \n 2022-06-30 11:38:28 UTC\n \n 2023-08-15 11:50: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 1565\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:38:28',4,'2023-08-15 13:50:29',4,0,NULL,NULL,NULL,'9612971e-a174-4a5f-8fbd-59eec5a601b2'),(1566,'Clients given 5E weighing >=35kg','Clients given 5E weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing >=35kg\n Clients given 5E weighing >=35kg\n \n 2022-06-30 11:38:46 UTC\n \n 2023-08-15 12: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 1566\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 \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 \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 (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 >= 35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:38:46',4,'2023-08-15 14:08:51',4,0,NULL,NULL,NULL,'8e471ec5-2e65-4ade-9508-52eabac321a3'),(1567,'Clients given 6F weighing 0-3.9kg','Clients given 6F weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 0-3.9kg\n Clients given 6F weighing 0-3.9kg\n \n 2022-06-30 11:41:42 UTC\n \n 2023-08-15 11:55: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 1567\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:41:42',4,'2023-08-15 13:55:19',4,0,NULL,NULL,NULL,'21f2534a-381c-427b-85d0-2e8a156f55cc'),(1568,'Clients given 6A weighing 4-5.9kg','Clients given 6A weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 4-5.9kg\n Clients given 6A weighing 4-5.9kg\n \n 2022-06-30 11:42:04 UTC\n \n 2023-08-15 11:58: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 1568\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:42:04',4,'2023-08-15 13:58:40',4,0,NULL,NULL,NULL,'349f5e74-fd1f-46ca-b279-089ec17daa3c'),(1569,'Clients given 6F weighing 4-5.9kg','Clients given 6F weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 4-5.9kg\n Clients given 6F weighing 4-5.9kg\n \n 2022-06-30 11:42:52 UTC\n \n 2023-08-15 12:01: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 1569\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:42:52',4,'2023-08-15 14:01:56',4,0,NULL,NULL,NULL,'6d6fd933-e915-4eb2-aa0a-5f9a3fc39c9e'),(1570,'Clients given 6A weighing 6-9.9kg','Clients given 6A weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 6-9.9kg\n Clients given 6A weighing 6-9.9kg\n \n 2022-06-30 11:42:56 UTC\n \n 2023-08-15 12:07: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 1570\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:42:56',4,'2023-08-15 14:07:06',4,0,NULL,NULL,NULL,'d6cf3e57-fba8-4961-83e9-e0c69b152e91'),(1571,'Clients given 6F weighing 6-9.9kg','Clients given 6F weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 6-9.9kg\n Clients given 6F weighing 6-9.9kg\n \n 2022-06-30 11:43:28 UTC\n \n 2023-08-15 12:11: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 1571\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:43:28',4,'2023-08-15 14:11:18',4,0,NULL,NULL,NULL,'07ebdb1b-42fd-4338-9880-b53a0e857d14'),(1572,'Clients given 6A weighing 10-13.9kg','Clients given 6A weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 10-13.9kg\n Clients given 6A weighing 10-13.9kg\n \n 2022-06-30 11:43:45 UTC\n \n 2023-08-15 12:19: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 1572\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:43:45',4,'2023-08-15 14:19:36',4,0,NULL,NULL,NULL,'de6af126-f558-4acf-b061-982dbfac0025'),(1573,'Clients given 6F weighing 10-13.9kg','Clients given 6F weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 10-13.9kg\n Clients given 6F weighing 10-13.9kg\n \n 2022-06-30 11:44:06 UTC\n \n 2023-08-15 12:14: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 1573\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:44:06',4,'2023-08-15 14:14:29',4,0,NULL,NULL,NULL,'e77aeb5b-70e2-46a1-9451-be37911a5dc0'),(1574,'Clients given 6A weighing 14-19.9kg','Clients given 6A weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 14-19.9kg\n Clients given 6A weighing 14-19.9kg\n \n 2022-06-30 11:44:40 UTC\n \n 2023-08-15 13:36: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 1574\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:44:40',4,'2023-08-15 15:36:18',4,0,NULL,NULL,NULL,'6850d21e-415b-4941-aa12-ddcf45ebf1cf'),(1575,'Clients given 6F weighing 14-19.9kg','Clients given 6F weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 14-19.9kg\n Clients given 6F weighing 14-19.9kg\n \n 2022-06-30 11:44:51 UTC\n \n 2023-08-15 13:39: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 1575\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:44:51',4,'2023-08-15 15:39:53',4,0,NULL,NULL,NULL,'bffbdb83-5c53-4429-baca-46ef480cbbdd'),(1576,'Clients given 6A weighing 20-24.9kg','Clients given 6A weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 20-24.9kg\n Clients given 6A weighing 20-24.9kg\n \n 2022-06-30 11:45:34 UTC\n \n 2023-08-15 13:43: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 1576\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 \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 \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 (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','2022-06-30 13:45:34',4,'2023-08-15 15:43:08',4,0,NULL,NULL,NULL,'00c9ee8c-dd26-4de8-8d76-65235331fc58'),(1577,'Clients given 6F weighing 20-24.9kg','Clients given 6F weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 20-24.9kg\n Clients given 6F weighing 20-24.9kg\n \n 2022-06-30 11:45:40 UTC\n \n 2023-08-15 13:46: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 1577\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 \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 \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 (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','2022-06-30 13:45:40',4,'2023-08-15 15:46:12',4,0,NULL,NULL,NULL,'1907619e-e315-4136-b63d-ebb12d9a8fc1'),(1578,'Clients given 6F weighing 25-34.9kg','Clients given 6F weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 25-34.9kg\n Clients given 6F weighing 25-34.9kg\n \n 2022-06-30 11:46:30 UTC\n \n 2023-08-15 13: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 1578\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:46:30',4,'2023-08-15 15:54:43',4,0,NULL,NULL,NULL,'67151923-545c-44f9-955c-705bd4b86bd8'),(1579,'Clients given 6A weighing 25-34.9kg','Clients given 6A weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 25-34.9kg\n Clients given 6A weighing 25-34.9kg\n \n 2022-06-30 11:46:33 UTC\n \n 2023-08-15 13:52: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 1579\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:46:33',4,'2023-08-15 15:52:05',4,0,NULL,NULL,NULL,'c4410a3f-a272-4f5a-8b68-c293b482c8f2'),(1580,'Clients given 6F weighing >=35kg','Clients given 6F weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing >=35kg\n Clients given 6F weighing >=35kg\n \n 2022-06-30 11:47:14 UTC\n \n 2023-08-15 14:01: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 1580\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:47:14',4,'2023-08-15 16:01:34',4,0,NULL,NULL,NULL,'88e71ca5-8e27-438a-ad22-12007acc675a'),(1581,'Clients given 6A weighing >= 35kg','Clients given 6A weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing >= 35kg\n Clients given 6A weighing >= 35kg\n \n 2022-06-30 11:47:26 UTC\n \n 2023-08-15 13:58: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 1581\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:47:26',4,'2023-08-15 15:58:50',4,0,NULL,NULL,NULL,'120fc355-ea4b-4d74-9df3-713f396ad4d5'),(1582,'Clients given 6B weighing 0-3.9kg','Clients given 6B weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 0-3.9kg\n Clients given 6B weighing 0-3.9kg\n \n 2022-06-30 11:49:06 UTC\n \n 2023-08-15 11:51: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 1582\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:49:06',4,'2023-08-15 13:51:04',4,0,NULL,NULL,NULL,'c94b83be-7708-46c9-803c-369d803ce612'),(1583,'Clients given 6E weighing 0-3.9kg','Clients given 6E weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 0-3.9kg\n Clients given 6E weighing 0-3.9kg\n \n 2022-06-30 11:49:10 UTC\n \n 2023-08-15 11:55: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 1583\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:49:10',4,'2023-08-15 13:55:28',4,0,NULL,NULL,NULL,'79f4464f-be3a-4f76-b911-1324264edb34'),(1584,'Clients given 6E weighing 4-5.9kg','Clients given 6E weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 4-5.9kg\n Clients given 6E weighing 4-5.9kg\n \n 2022-06-30 11:50:19 UTC\n \n 2023-08-15 12:02: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 1584\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:50:19',4,'2023-08-15 14:02:30',4,0,NULL,NULL,NULL,'c940a6d2-b183-4f3d-99c3-757c98c1d95d'),(1585,'Clients given 6B weighing 4-5.9kg','Clients given 6B weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 4-5.9kg\n Clients given 6B weighing 4-5.9kg\n \n 2022-06-30 11:50:41 UTC\n \n 2023-08-15 12:03: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 1585\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:50:41',4,'2023-08-15 14:03:18',4,0,NULL,NULL,NULL,'b03e49d3-e03b-4a31-b0c9-dc33942ca80b'),(1586,'Clients given 6E weighing 6-9.9kg','Clients given 6E weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 6-9.9kg\n Clients given 6E weighing 6-9.9kg\n \n 2022-06-30 11:51:01 UTC\n \n 2023-08-15 12: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 1586\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:51:01',4,'2023-08-15 14:11:10',4,0,NULL,NULL,NULL,'b0f0ed35-fe90-4552-83a7-e10c1b509fdb'),(1587,'Clients given 6B weighing 6-9.9kg','Clients given 6B weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 6-9.9kg\n Clients given 6B weighing 6-9.9kg\n \n 2022-06-30 11:51:24 UTC\n \n 2023-08-15 12:07: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 1587\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:51:24',4,'2023-08-15 14:07:40',4,0,NULL,NULL,NULL,'9b75e9b1-6086-4d10-aa5d-f574d58c2f9b'),(1588,'Clients given 6E weighing 10-13.9kg','Clients given 6E weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 10-13.9kg\n Clients given 6E weighing 10-13.9kg\n \n 2022-06-30 11:51:37 UTC\n \n 2023-08-15 12:15: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 1588\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:51:37',4,'2023-08-15 14:15:07',4,0,NULL,NULL,NULL,'4ab54017-730b-443b-b1a4-c7fb57c16069'),(1589,'Clients given 6B weighing 10-13.9kg','Clients given 6B weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 10-13.9kg\n Clients given 6B weighing 10-13.9kg\n \n 2022-06-30 11:52:19 UTC\n \n 2023-08-15 12:18: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 1589\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:52:19',4,'2023-08-15 14:18:48',4,0,NULL,NULL,NULL,'439b52c1-c9d5-4366-9819-994f121bf0fa'),(1590,'Clients given 6E weighing 14-19.9kg','Clients given 6E weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 14-19.9kg\n Clients given 6E weighing 14-19.9kg\n \n 2022-06-30 11:52:28 UTC\n \n 2023-08-15 13:39: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 1590\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:52:28',4,'2023-08-15 15:39:35',4,0,NULL,NULL,NULL,'4a2873d6-97bb-42b9-8e4f-4786bf854462'),(1591,'Clients given 6E weighing 20-24.9kg','Clients given 6E weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 20-24.9kg\n Clients given 6E weighing 20-24.9kg\n \n 2022-06-30 11:53:12 UTC\n \n 2023-08-15 13:45: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 1591\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 \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 \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 (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','2022-06-30 13:53:12',4,'2023-08-15 15:45:54',4,0,NULL,NULL,NULL,'e129484c-9b6b-4ed5-a0b8-da691370e459'),(1592,'Clients given 6B weighing 14-19.9kg','Clients given 6B weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 14-19.9kg\n Clients given 6B weighing 14-19.9kg\n \n 2022-06-30 11:53:32 UTC\n \n 2023-08-15 13:38: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 1592\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:53:32',4,'2023-08-15 15:38:03',4,0,NULL,NULL,NULL,'af7d5255-1e37-4def-b26d-dcded87c1ded'),(1593,'Clients given 6E weighing 25-34.9kg','Clients given 6E weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 25-34.9kg\n Clients given 6E weighing 25-34.9kg\n \n 2022-06-30 11:54:08 UTC\n \n 2023-08-15 13:54: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 1593\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:54:08',4,'2023-08-15 15:54:22',4,0,NULL,NULL,NULL,'5c8f4cdd-6c22-4df0-8d12-801a66ccff55'),(1594,'Clients given 6B weighing 20-24.9kg','Clients given 6B weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 20-24.9kg\n Clients given 6B weighing 20-24.9kg\n \n 2022-06-30 11:54:35 UTC\n \n 2023-08-15 13:43: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 1594\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 \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 \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 (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','2022-06-30 13:54:35',4,'2023-08-15 15:43:29',4,0,NULL,NULL,NULL,'3d5ca230-bb1a-40ad-9a13-ae3d4a7868c1'),(1595,'Clients given 6E weighing >=35kg','Clients given 6E weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing >=35kg\n Clients given 6E weighing >=35kg\n \n 2022-06-30 11:54:50 UTC\n \n 2023-08-15 14: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 1595\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:54:50',4,'2023-08-15 16:01:10',4,0,NULL,NULL,NULL,'0ed30402-06d4-4a91-ab30-8aa4cb05f973'),(1596,'Clients given 6B weighing 25-34.9kg','Clients given 6B weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 25-34.9kg\n Clients given 6B weighing 25-34.9kg\n \n 2022-06-30 11:55:30 UTC\n \n 2023-08-15 13:52: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 1596\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:55:30',4,'2023-08-15 15:52:19',4,0,NULL,NULL,NULL,'760b7d9e-5a7e-4a13-9517-59f18a299d60'),(1597,'Clients given 6B weighing >= 35kg','Clients given 6B weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing >= 35kg\n Clients given 6B weighing >= 35kg\n \n 2022-06-30 11:56:44 UTC\n \n 2023-08-15 14:00: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 1597\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:56:44',4,'2023-08-15 16:00:19',4,0,NULL,NULL,NULL,'89e94627-eb6a-4b05-8b5c-7c06482c67da'),(1598,'Clients given 6D weighing 0-3.9kg','Clients given 6D weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 0-3.9kg\n Clients given 6D weighing 0-3.9kg\n \n 2022-06-30 11:57:07 UTC\n \n 2023-08-15 11:55: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 1598\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:57:07',4,'2023-08-15 13:55:38',4,0,NULL,NULL,NULL,'c5ecfc78-4201-495c-9c7d-042b046d6c3d'),(1599,'Clients given 6D weighing 4-5.9kg','Clients given 6D weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 4-5.9kg\n Clients given 6D weighing 4-5.9kg\n \n 2022-06-30 11:57:58 UTC\n \n 2023-08-15 12:02: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 1599\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:57:58',4,'2023-08-15 14:02:40',4,0,NULL,NULL,NULL,'25950d8e-2a7a-484f-8674-e94ba2fc9071'),(1600,'Clients given 6C weighing 0-3.9kg','Clients given 6C weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 0-3.9kg\n Clients given 6C weighing 0-3.9kg\n \n 2022-06-30 11:58:17 UTC\n \n 2023-08-15 11:52: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 1600\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:58:17',4,'2023-08-15 13:52:01',4,0,NULL,NULL,NULL,'6eff51d3-2d07-44db-a617-ff288d027867'),(1601,'Clients given 6D weighing 6-9.9kg','Clients given 6D weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 6-9.9kg\n Clients given 6D weighing 6-9.9kg\n \n 2022-06-30 11:58:42 UTC\n \n 2023-08-15 12:10: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 1601\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:58:42',4,'2023-08-15 14:10:38',4,0,NULL,NULL,NULL,'0b2e111f-f266-4a34-ba0b-4080607ca595'),(1602,'Clients given 6D weighing 10-13.9kg','Clients given 6D weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 10-13.9kg\n Clients given 6D weighing 10-13.9kg\n \n 2022-06-30 11:59:37 UTC\n \n 2023-08-15 12:15: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 1602\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:59:37',4,'2023-08-15 14:15:29',4,0,NULL,NULL,NULL,'d13d961e-4f19-4d97-88f5-f0795b285859'),(1603,'Clients given 6D weighing 14-19.9kg','Clients given 6D weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 14-19.9kg\n Clients given 6D weighing 14-19.9kg\n \n 2022-06-30 12:00:32 UTC\n \n 2023-08-15 13:39: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 1603\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:00:32',4,'2023-08-15 15:39:12',4,0,NULL,NULL,NULL,'ba0967aa-34e7-4df6-a75b-cbe7c8b52cea'),(1604,'Clients given 6C weighing 4-5.9kg','Clients given 6C weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 4-5.9kg\n Clients given 6C weighing 4-5.9kg\n \n 2022-06-30 12:00:54 UTC\n \n 2023-08-15 12:02: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 1604\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:00:54',4,'2023-08-15 14:02:57',4,0,NULL,NULL,NULL,'9538730a-29f7-45cc-a6e5-4b20a1b80f2f'),(1605,'Clients given 6D weighing 20-24.9kg','Clients given 6D weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 20-24.9kg\n Clients given 6D weighing 20-24.9kg\n \n 2022-06-30 12:01:12 UTC\n \n 2023-08-15 13:45: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 1605\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 \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 \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 (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','2022-06-30 14:01:12',4,'2023-08-15 15:45:42',4,0,NULL,NULL,NULL,'87b14d09-b20e-47d1-b20e-c38bc338df15'),(1606,'Clients given 6D weighing 25-34.9kg','Clients given 6D weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 25-34.9kg\n Clients given 6D weighing 25-34.9kg\n \n 2022-06-30 12:01:59 UTC\n \n 2023-08-15 13: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 1606\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:01:59',4,'2023-08-15 15:54:05',4,0,NULL,NULL,NULL,'9b8508f6-6c59-4408-90d1-4366ad9f3df7'),(1607,'Clients given 6C weighing 6-9.9kg','Clients given 6C weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 6-9.9kg\n Clients given 6C weighing 6-9.9kg\n \n 2022-06-30 12:02:20 UTC\n \n 2023-08-15 12:08: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 1607\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:02:20',4,'2023-08-15 14:08:10',4,0,NULL,NULL,NULL,'021aecf8-4314-4feb-921d-dbab609bce88'),(1608,'Clients given 6D weighing >=35kg','Clients given 6D weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing >=35kg\n Clients given 6D weighing >=35kg\n \n 2022-06-30 12:02:42 UTC\n \n 2023-08-15 14:00: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 1608\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:02:42',4,'2023-08-15 16:00:51',4,0,NULL,NULL,NULL,'6b8cf9ee-1659-46da-8aab-1580ccd82fe7'),(1609,'Clients given 6C weighing 10-13.9kg','Clients given 6C weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 10-13.9kg\n Clients given 6C weighing 10-13.9kg\n \n 2022-06-30 12:03:07 UTC\n \n 2023-08-15 12:15: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 1609\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:03:07',4,'2023-08-15 14:15:45',4,0,NULL,NULL,NULL,'e43ddc56-97c9-4c2b-9dd1-4439ab2d154e'),(1610,'Clients given 6C weighing 14-19.9kg','Clients given 6C weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 14-19.9kg\n Clients given 6C weighing 14-19.9kg\n \n 2022-06-30 12:03:52 UTC\n \n 2023-08-15 13:38: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 1610\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:03:52',4,'2023-08-15 15:38:51',4,0,NULL,NULL,NULL,'7cc34bd7-01dc-4e10-97b4-3aabce82e0d2'),(1611,'Clients given 6C weighing 20-24.9kg','Clients given 6C weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 20-24.9kg\n Clients given 6C weighing 20-24.9kg\n \n 2022-06-30 12:05:08 UTC\n \n 2023-08-15 13:45: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 1611\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 \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 \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 (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','2022-06-30 14:05:08',4,'2023-08-15 15:45:29',4,0,NULL,NULL,NULL,'eb9fff17-d2d9-4c0a-a4ff-919fe86f2cfe'),(1612,'Clients given 6C weighing 25-34.9kg','Clients given 6C weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 25-34.9kg\n Clients given 6C weighing 25-34.9kg\n \n 2022-06-30 12:06:35 UTC\n \n 2023-08-15 13:52: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 1612\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:06:35',4,'2023-08-15 15:52:38',4,0,NULL,NULL,NULL,'95004055-2dd1-4b3c-9536-877974c6fc23'),(1613,'Clients given 6C weighing >= 35kg','Clients given 6C weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing >= 35kg\n Clients given 6C weighing >= 35kg\n \n 2022-06-30 12:07:48 UTC\n \n 2023-08-15 14:00: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 1613\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:07:48',4,'2023-08-15 16:00:36',4,0,NULL,NULL,NULL,'a5659098-23a4-41c0-8bbd-12dd4c9bca64'),(1614,'Clients given 4C weighing 0-3.9kg','Clients given 4C weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.SqlIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 0-3.9kg\n Clients given 4C weighing 0-3.9kg\n \n 2022-06-30 12:15:27 UTC\n \n','2022-06-30 14:15:27',4,NULL,NULL,0,NULL,NULL,NULL,'46894193-4656-4941-9050-4498338da679'),(1615,'Clients given 4C weighing 0-3.9kg','Clients given 4C weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 0-3.9kg\n Clients given 4C weighing 0-3.9kg\n \n 2022-06-30 12:16:38 UTC\n \n 2022-06-30 12:20: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 1615\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:16:38',4,'2022-06-30 14:20:27',4,0,NULL,NULL,NULL,'4a2b667a-930c-4d98-9073-18aa9e6104ec'),(1616,'Clients given 4C weighing 4-5.9kg','Clients given 4C weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 4-5.9kg\n Clients given 4C weighing 4-5.9kg\n \n 2022-06-30 12:21:22 UTC\n \n 2022-06-30 12: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 1616\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:21:22',4,'2022-06-30 14:23:05',4,0,NULL,NULL,NULL,'aa294dde-6440-4b72-ab4a-d5b782cec371'),(1617,'Clients given 4C weighing 6-9.9kg','Clients given 4C weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 6-9.9kg\n Clients given 4C weighing 6-9.9kg\n \n 2022-06-30 12:23:45 UTC\n \n 2022-06-30 12:24: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 1617\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:23:45',4,'2022-06-30 14:24:45',4,0,NULL,NULL,NULL,'5a98d199-a896-47ec-830e-56cd2fef0351'),(1618,'Clients given 4C weighing 10-13.9kg','Clients given 4C weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 10-13.9kg\n Clients given 4C weighing 10-13.9kg\n \n 2022-06-30 12:25:23 UTC\n \n 2022-06-30 12:26: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 1618\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:25:23',4,'2022-06-30 14:26:36',4,0,NULL,NULL,NULL,'bc8cd79c-b1fd-4956-8f87-596d56a8b0b9'),(1619,'Clients given 4C weighing 14-19.9kg','Clients given 4C weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 14-19.9kg\n Clients given 4C weighing 14-19.9kg\n \n 2022-06-30 12:27:19 UTC\n \n 2022-06-30 12:28: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 1619\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:27:19',4,'2022-06-30 14:28:17',4,0,NULL,NULL,NULL,'220abe15-cbb2-464a-bb57-fb1e75ad56c6'),(1620,'Clients given 4C weighing 20-24.9kg','Clients given 4C weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 20-24.9kg\n Clients given 4C weighing 20-24.9kg\n \n 2022-06-30 12:28:52 UTC\n \n 2022-06-30 12: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 1620\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:28:52',4,'2022-06-30 14:29:51',4,0,NULL,NULL,NULL,'0e4c3cca-5e54-4f77-a359-6c5a47141593'),(1621,'Clients given 4C weighing 25-34.9kg','Clients given 4C weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 25-34.9kg\n Clients given 4C weighing 25-34.9kg\n \n 2022-06-30 12:30:29 UTC\n \n 2022-06-30 12:31: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 1621\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:30:29',4,'2022-06-30 14:31:26',4,0,NULL,NULL,NULL,'d1810771-902c-44c5-b1a9-988f037cf87d'),(1622,'Clients given 4C weighing >= 35kg','Clients given 4C weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing >= 35kg\n Clients given 4C weighing >= 35kg\n \n 2022-06-30 12:32:03 UTC\n \n 2022-06-30 12:33: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 1622\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:32:03',4,'2022-06-30 14:33:13',4,0,NULL,NULL,NULL,'1d840c5f-240c-4159-8a72-6b0db642b53f'),(1623,'Clients given 4D weighing 0-3.9kg','Clients given 4D weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 0-3.9kg\n Clients given 4D weighing 0-3.9kg\n \n 2022-06-30 12:33:59 UTC\n \n 2022-06-30 12:36: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 1623\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:33:59',4,'2022-06-30 14:36:06',4,0,NULL,NULL,NULL,'0746d03a-e518-473c-809e-f764e275f42a'),(1624,'Clients given 4D weighing 4-5.9kg','Clients given 4D weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 4-5.9kg\n Clients given 4D weighing 4-5.9kg\n \n 2022-06-30 12:36:44 UTC\n \n 2022-06-30 12:38: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 1624\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:36:44',4,'2022-06-30 14:38:51',4,0,NULL,NULL,NULL,'fdaff2b0-2a93-4eed-8a21-37b4493a93d8'),(1625,'Clients given 4D weighing 6-9.9kg','Clients given 4D weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 6-9.9kg\n Clients given 4D weighing 6-9.9kg\n \n 2022-06-30 12:37:11 UTC\n \n 2022-06-30 12:39: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 1625\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:37:11',4,'2022-06-30 14:39:41',4,0,NULL,NULL,NULL,'f7342534-15b0-4b7f-abf7-4689c7510e5d'),(1626,'Clients given 4D weighing 10-13.9kg','Clients given 4D weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 10-13.9kg\n Clients given 4D weighing 10-13.9kg\n \n 2022-06-30 12:40:08 UTC\n \n 2022-06-30 12:40: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 1626\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:40:08',4,'2022-06-30 14:40:58',4,0,NULL,NULL,NULL,'f70b046a-7684-4087-85ac-b8e890c99a7d'),(1627,'Clients given 4D weighing 14-19.9kg','Clients given 4D weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 14-19.9kg\n Clients given 4D weighing 14-19.9kg\n \n 2022-06-30 12:41:22 UTC\n \n 2022-06-30 12:46: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 1627\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:41:22',4,'2022-06-30 14:46:15',4,0,NULL,NULL,NULL,'a78b89dd-1172-4ae3-9db1-252697c46714'),(1628,'Children ARV Regimen_1stLine_2022','Children ARV Regimen_1stLine','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_2022\n Children ARV Regimen_1stLine\n \n 2022-06-30 12:44:42 UTC\n \n 2022-06-30 12:44: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 1628\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','2022-06-30 14:44:42',4,'2022-06-30 14:44:52',4,0,NULL,NULL,NULL,'6d96f107-4e14-48ff-b6d7-c845d87e37e1'),(1629,'Children ARV Regimen_1stLine_2022 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_2022 Data Set\n \n 2022-06-30 12:44:52 UTC\n \n 2022-06-30 19:13: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 1629\n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 4C0to3.9\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_Age\n Children 0to14\n \n \n \n \n \n 4C10to13.9\n \n \n \n \n \n \n \n \n \n 4C14to19.9\n \n \n \n \n \n \n \n \n \n 4C20to24.9\n \n \n \n \n \n \n \n \n \n 4C25to34.9\n \n \n \n \n \n \n \n \n \n 4C35plus\n \n \n \n \n \n \n \n \n \n 4C4to5.9\n \n \n \n \n \n \n \n \n \n 4C6to9.9\n \n \n \n \n \n \n \n \n \n 4D0to3.9\n \n \n \n \n \n \n \n \n \n 4D10to13.9\n \n \n \n \n \n \n \n \n \n 4D14to19.9\n \n \n \n \n \n \n \n \n \n 4D20to24.9\n \n \n \n \n \n \n \n \n \n 4D25to34.9\n \n \n \n \n \n \n \n \n \n 4D35plus\n \n \n \n \n \n \n \n \n \n 4D4to5.9\n \n \n \n \n \n \n \n \n \n 4D6to9.9\n \n \n \n \n \n \n \n \n \n 4E0to3.9\n \n \n \n \n \n \n \n \n \n 4E10to13.9\n \n \n \n \n \n \n \n \n \n 4E14to19.9\n \n \n \n \n \n \n \n \n \n 4E20to24.9\n \n \n \n \n \n \n \n \n \n 4E25to34.9\n \n \n \n \n \n \n \n \n \n 4E35plus\n \n \n \n \n \n \n \n \n \n 4E4to5.9\n \n \n \n \n \n \n \n \n \n 4E6to9.9\n \n \n \n \n \n \n \n \n \n 4F0to3.9\n \n \n \n \n \n \n \n \n \n 4F10to13.9\n \n \n \n \n \n \n \n \n \n 4F14to19.9\n \n \n \n \n \n \n \n \n \n 4F20to24.9\n \n \n \n \n \n \n \n \n \n 4F25to34.9\n \n \n \n \n \n \n \n \n \n 4F35plus\n \n \n \n \n \n \n \n \n \n 4F4to5.9\n \n \n \n \n \n \n \n \n \n 4F6to9.9\n \n \n \n \n \n \n \n \n \n 4G0to3.9\n \n \n \n \n \n \n \n \n \n 4G10to13.9\n \n \n \n \n \n \n \n \n \n 4G14to19.9\n \n \n \n \n \n \n \n \n \n 4G20to24.9\n \n \n \n \n \n \n \n \n \n 4G25to34.9\n \n \n \n \n \n \n \n \n \n 4G35plus\n \n \n \n \n \n \n \n \n \n 4G4to5.9\n \n \n \n \n \n \n \n \n \n 4G6to9.9\n \n \n \n \n \n \n \n \n \n 4H0to3.9\n \n \n \n \n \n \n \n \n \n 4H10to13.9\n \n \n \n \n \n \n \n \n \n 4H14to19.9\n \n \n \n \n \n \n \n \n \n 4H20to24.9\n \n \n \n \n \n \n \n \n \n 4H25to34.9\n \n \n \n \n \n \n \n \n \n 4H35plus\n \n \n \n \n \n \n \n \n \n 4H4to5.9\n \n \n \n \n \n \n \n \n \n 4H6to9.9\n \n \n \n \n \n \n \n \n \n 4J0to3.9\n \n \n \n \n \n \n \n \n \n 4J10to13.9\n \n \n \n \n \n \n \n \n \n 4J14to19.9\n \n \n \n \n \n \n \n \n \n 4J20to24.9\n \n \n \n \n \n \n \n \n \n 4J25to34.9\n \n \n \n \n \n \n \n \n \n 4J35plus\n \n \n \n \n \n \n \n \n \n 4J4to5.9\n \n \n \n \n \n \n \n \n \n 4J6to9.9\n \n \n \n \n \n \n \n \n \n 4K0to3.9\n \n \n \n \n \n \n \n \n \n 4K10to13.9\n \n \n \n \n \n \n \n \n \n 4K14to19.9\n \n \n \n \n \n \n \n \n \n 4K20to24.9\n \n \n \n \n \n \n \n \n \n 4K25to34.9\n \n \n \n \n \n \n \n \n \n 4K35plus\n \n \n \n \n \n \n \n \n \n 4K4to5.9\n \n \n \n \n \n \n \n \n \n 4K6to9.9\n \n \n \n \n \n \n \n \n \n 4L0to3.9\n \n \n \n \n \n \n \n \n \n 4L10to13.9\n \n \n \n \n \n \n \n \n \n 4L14to19.9\n \n \n \n \n \n \n \n \n \n 4L20to24.9\n \n \n \n \n \n \n \n \n \n 4L25to34.9\n \n \n \n \n \n \n \n \n \n 4L35plus\n \n \n \n \n \n \n \n \n \n 4L4to5.9\n \n \n \n \n \n \n \n \n \n 4L6to9.9\n \n \n \n \n \n \n \n \n \n','2022-06-30 12:44:52',4,'2022-06-30 19:13:55',4,0,NULL,NULL,NULL,'72dc6096-f429-4c40-93bf-fbf45c22d970'),(1630,'Clients given 4D weighing 20-24.9kg','Clients given 4D weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 20-24.9kg\n Clients given 4D weighing 20-24.9kg\n \n 2022-06-30 12:46:40 UTC\n \n 2022-06-30 12:47: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 1630\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:46:40',4,'2022-06-30 14:47:39',4,0,NULL,NULL,NULL,'6c0b4f36-cc2c-4d85-a2ad-c5b5bf36b66b'),(1631,'Clients given 4D weighing 25-34.9kg','Clients given 4D weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 25-34.9kg\n Clients given 4D weighing 25-34.9kg\n \n 2022-06-30 12:48:05 UTC\n \n 2022-06-30 12:49: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 1631\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:48:05',4,'2022-06-30 14:49:27',4,0,NULL,NULL,NULL,'1c5157a7-08d8-4eb5-99df-f2ca1825baaa'),(1632,'Clients given 4D weighing >= 35kg','Clients given 4D weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing >= 35kg\n Clients given 4D weighing >= 35kg\n \n 2022-06-30 12:48:59 UTC\n \n 2022-06-30 12:50: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 1632\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:48:59',4,'2022-06-30 14:50:46',4,0,NULL,NULL,NULL,'5cbfb29b-e0b1-42b0-b7f5-a1b561ae3bb5'),(1633,'Clients given 4E weighing 0-3.9kg','Clients given 4E weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 0-3.9kg\n Clients given 4E weighing 0-3.9kg\n \n 2022-06-30 12:50:28 UTC\n \n 2022-06-30 12:54: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 1633\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:50:28',4,'2022-06-30 14:54:40',4,0,NULL,NULL,NULL,'36f7fe8c-f369-4152-a361-bc941ca32f35'),(1634,'Clients given 4E weighing 4-5.9kg','Clients given 4E weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 4-5.9kg\n Clients given 4E weighing 4-5.9kg\n \n 2022-06-30 12:54:09 UTC\n \n 2022-06-30 12:55: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 1634\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:54:09',4,'2022-06-30 14:55:44',4,0,NULL,NULL,NULL,'d6c46caf-e87c-4654-963f-91039f99e100'),(1635,'Clients given 4E weighing 6-9.9kg','Clients given 4E weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 6-9.9kg\n Clients given 4E weighing 6-9.9kg\n \n 2022-06-30 12:57:00 UTC\n \n 2022-06-30 13:15: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 1635\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:57:00',4,'2022-06-30 15:15:29',4,0,NULL,NULL,NULL,'2c954752-aaeb-427b-8cef-714be116f8d5'),(1636,'Clients given 4E weighing 10-13.9kg','Clients given 4E weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 10-13.9kg\n Clients given 4E weighing 10-13.9kg\n \n 2022-06-30 13:16:23 UTC\n \n 2022-06-30 13:20: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 1636\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:16:23',4,'2022-06-30 15:20:47',4,0,NULL,NULL,NULL,'92eb0675-5667-4202-ae12-91e31e89bc0a'),(1637,'Clients given 4K weighing 0-3.9kg','Clients given 4K weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 0-3.9kg\n Clients given 4K weighing 0-3.9kg\n \n 2022-06-30 13:21:01 UTC\n \n 2022-06-30 13:22: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 1637\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:21:01',4,'2022-06-30 15:22:04',4,0,NULL,NULL,NULL,'5166d416-8394-41a8-a7bf-cddf0f4573f9'),(1638,'Clients given 4E weighing 14-19.9kg','Clients given 4E weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 14-19.9kg\n Clients given 4E weighing 14-19.9kg\n \n 2022-06-30 13:21:21 UTC\n \n 2022-06-30 13:23: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 1638\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:21:21',4,'2022-06-30 15:23:24',4,0,NULL,NULL,NULL,'7c801f27-0d0e-4f8e-8d16-c9abbbc1d70f'),(1639,'Clients given 4K weighing 4-5.9kg','Clients given 4K weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 4-5.9kg\n Clients given 4K weighing 4-5.9kg\n \n 2022-06-30 13:22:30 UTC\n \n 2022-06-30 13:23: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 1639\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:22:30',4,'2022-06-30 15:23:19',4,0,NULL,NULL,NULL,'c3840473-881e-4c28-8b70-08ee65d51205'),(1640,'Clients given 4E weighing 20-24.9kg','Clients given 4E weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 20-24.9kg\n Clients given 4E weighing 20-24.9kg\n \n 2022-06-30 13:22:54 UTC\n \n 2022-06-30 13:24: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 1640\n COUNT\n \n \n \n \n endDate\n ${startDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:22:54',4,'2022-06-30 15:24:23',4,0,NULL,NULL,NULL,'7171def2-3caa-415e-8d0c-ae70c50ee52a'),(1641,'Clients given 4K weighing 6-9.9kg','Clients given 4K weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 6-9.9kg\n Clients given 4K weighing 6-9.9kg\n \n 2022-06-30 13:23:54 UTC\n \n 2022-06-30 13:24: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 1641\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:23:54',4,'2022-06-30 15:24:45',4,0,NULL,NULL,NULL,'2dc1198d-9268-4a29-b96d-7ac8921d3551'),(1642,'Clients given 4E weighing 25-34.9kg','Clients given 4E weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 25-34.9kg\n Clients given 4E weighing 25-34.9kg\n \n 2022-06-30 13:24:00 UTC\n \n 2022-06-30 13:25: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 1642\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:24:00',4,'2022-06-30 15:25:27',4,0,NULL,NULL,NULL,'40ac2a8b-12d5-4b3d-bea2-b63e3d969db9'),(1643,'Clients given 4E weighing >= 35kg','Clients given 4E weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing >= 35kg\n Clients given 4E weighing >= 35kg\n \n 2022-06-30 13:25:02 UTC\n \n 2022-06-30 13:26: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 1643\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:25:02',4,'2022-06-30 15:26:56',4,0,NULL,NULL,NULL,'9f104324-88d3-4be9-8a9e-2535e4368371'),(1644,'Clients given 4K weighing 10-13.9kg','Clients given 4K weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 10-13.9kg\n Clients given 4K weighing 10-13.9kg\n \n 2022-06-30 13:25:05 UTC\n \n 2022-06-30 13:26: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 1644\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:25:05',4,'2022-06-30 15:26:01',4,0,NULL,NULL,NULL,'38fbaae4-791a-4bba-85ea-d149625c3d79'),(1645,'Clients given 4K weighing 14-19.9kg','Clients given 4K weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 14-19.9kg\n Clients given 4K weighing 14-19.9kg\n \n 2022-06-30 13:26:26 UTC\n \n 2022-06-30 13:27: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 1645\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:26:26',4,'2022-06-30 15:27:37',4,0,NULL,NULL,NULL,'c0be7036-edcf-4337-97d7-2bb22bc6ef54'),(1646,'Clients given 4F weighing 0-3.9kg','Clients given 4F weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 0-3.9kg\n Clients given 4F weighing 0-3.9kg\n \n 2022-06-30 13:26:29 UTC\n \n 2022-06-30 13:28: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 1646\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:26:29',4,'2022-06-30 15:28:31',4,0,NULL,NULL,NULL,'3df707cf-c633-4a85-ab9a-affe8619ca0e'),(1647,'Clients given 4K weighing 20-24.9kg','Clients given 4K weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 20-24.9kg\n Clients given 4K weighing 20-24.9kg\n \n 2022-06-30 13:26:52 UTC\n \n 2022-06-30 13:27: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 1647\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:26:52',4,'2022-06-30 15:27:51',4,0,NULL,NULL,NULL,'f1be8c70-bd5f-4b25-8703-ebc91a56a354'),(1648,'Clients given 4F weighing 4-5.9kg','Clients given 4F weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 4-5.9kg\n Clients given 4F weighing 4-5.9kg\n \n 2022-06-30 13:27:32 UTC\n \n 2022-06-30 13:28: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 1648\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:27:32',4,'2022-06-30 15:28:56',4,0,NULL,NULL,NULL,'651b9843-2f38-4e58-a87b-8d01b1e1b736'),(1649,'Clients given 4K weighing 25-34.9kg','Clients given 4K weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 25-34.9kg\n Clients given 4K weighing 25-34.9kg\n \n 2022-06-30 13:28:20 UTC\n \n 2022-06-30 13:29: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 1649\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:28:20',4,'2022-06-30 15:29:38',4,0,NULL,NULL,NULL,'4a021424-b101-4001-8078-cd6e93935845'),(1650,'Clients given 4K weighing >=35kg','Clients given 4K weighing >=35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing >=35kg\n Clients given 4K weighing >=35kg\n \n 2022-06-30 13:28:45 UTC\n \n 2022-06-30 13:29: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 1650\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:28:45',4,'2022-06-30 15:29:54',4,0,NULL,NULL,NULL,'86cffb6f-3533-48b5-a568-425a6d32e7e6'),(1651,'Clients given 4F weighing 6-9.9kg','Clients given 4F weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 6-9.9kg\n Clients given 4F weighing 6-9.9kg\n \n 2022-06-30 13:29:29 UTC\n \n 2022-06-30 13:33: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 1651\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:29:29',4,'2022-06-30 15:33:15',4,0,NULL,NULL,NULL,'0d1c19ab-8761-43c9-b362-a733800ce420'),(1652,'Clients given 4F weighing 10-13.9kg','Clients given 4F weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 10-13.9kg\n Clients given 4F weighing 10-13.9kg\n \n 2022-06-30 13:29:53 UTC\n \n 2022-06-30 13:31: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 1652\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:29:53',4,'2022-06-30 15:31:09',4,0,NULL,NULL,NULL,'0be49339-dac1-4872-9c6c-50fee86542d0'),(1653,'Clients given 4F weighing 14-19.9kg','Clients given 4F weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 14-19.9kg\n Clients given 4F weighing 14-19.9kg\n \n 2022-06-30 13:32:50 UTC\n \n 2022-06-30 13:34: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 1653\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:32:50',4,'2022-06-30 15:34:42',4,0,NULL,NULL,NULL,'10f82a49-a80e-4feb-8a54-5011945608bc'),(1654,'Clients given 4F weighing 20-24.9kg','Clients given 4F weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 20-24.9kg\n Clients given 4F weighing 20-24.9kg\n \n 2022-06-30 13:33:57 UTC\n \n 2022-06-30 13:35: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 1654\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:33:57',4,'2022-06-30 15:35:34',4,0,NULL,NULL,NULL,'1b492993-7168-4cee-aeae-ed3cb3136ef4'),(1655,'Clients given 4F weighing 25-34.9kg','Clients given 4F weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 25-34.9kg\n Clients given 4F weighing 25-34.9kg\n \n 2022-06-30 13:35:56 UTC\n \n 2022-06-30 13:37: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 1655\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:35:56',4,'2022-06-30 15:37:26',4,0,NULL,NULL,NULL,'fd363f21-64f5-4465-8f1c-94a10ec790bc'),(1656,'Clients given 4F weighing >= 35kg','Clients given 4F weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing >= 35kg\n Clients given 4F weighing >= 35kg\n \n 2022-06-30 13:36:27 UTC\n \n 2022-06-30 13:37: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 1656\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:36:27',4,'2022-06-30 15:37:46',4,0,NULL,NULL,NULL,'2ca64d93-82d9-40b9-ae24-669a1d529641'),(1657,'Clients given 4G weighing 0-3.9kg','Clients given 4G weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 0-3.9kg\n Clients given 4G weighing 0-3.9kg\n \n 2022-06-30 13:38:33 UTC\n \n 2022-06-30 13:39: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 1657\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:38:33',4,'2022-06-30 15:39:42',4,0,NULL,NULL,NULL,'e2b136d9-95a4-49fa-8069-476f5b7e1bc2'),(1658,'Clients given 4G weighing 4-5.9kg','Clients given 4G weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 4-5.9kg\n Clients given 4G weighing 4-5.9kg\n \n 2022-06-30 13:38:58 UTC\n \n 2022-06-30 13:40: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 1658\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:38:58',4,'2022-06-30 15:40:05',4,0,NULL,NULL,NULL,'dc8af817-8512-4a0a-b692-331377842479'),(1659,'Clients given 4G weighing 6-9.9kg','Clients given 4G weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 6-9.9kg\n Clients given 4G weighing 6-9.9kg\n \n 2022-06-30 13:40:27 UTC\n \n 2022-06-30 13:41: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 1659\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:40:27',4,'2022-06-30 15:41:40',4,0,NULL,NULL,NULL,'97f6acaa-3818-4efc-b6e0-8d8ecd3255b5'),(1660,'Clients given 4G weighing 10-13.9kg','Clients given 4G weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 10-13.9kg\n Clients given 4G weighing 10-13.9kg\n \n 2022-06-30 13:40:47 UTC\n \n 2022-06-30 13:43: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 1660\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:40:47',4,'2022-06-30 15:43:02',4,0,NULL,NULL,NULL,'ebcfa3fc-dea8-4a53-99f7-a16dc23a026c'),(1661,'Clients given 4G weighing 14-19.9kg','Clients given 4G weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 14-19.9kg\n Clients given 4G weighing 14-19.9kg\n \n 2022-06-30 13:42:19 UTC\n \n 2022-06-30 13:43: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 1661\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:42:19',4,'2022-06-30 15:43:59',4,0,NULL,NULL,NULL,'793e78bb-284c-47fa-8967-3fa124d3e9c7'),(1662,'Clients given 4G weighing 20-24.9kg','Clients given 4G weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 20-24.9kg\n Clients given 4G weighing 20-24.9kg\n \n 2022-06-30 13:43:37 UTC\n \n 2022-06-30 13:44: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 1662\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:43:37',4,'2022-06-30 15:44:44',4,0,NULL,NULL,NULL,'2bffd86c-c304-4fe5-bea0-dcba1ddacd30'),(1663,'Clients given 4G weighing 25-34.9kg','Clients given 4G weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 25-34.9kg\n Clients given 4G weighing 25-34.9kg\n \n 2022-06-30 13:44:57 UTC\n \n 2022-06-30 13:48: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 1663\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:44:57',4,'2022-06-30 15:48:30',4,0,NULL,NULL,NULL,'dff299fd-70e4-42b6-821b-24bbfca5d130'),(1664,'Clients given 4G weighing >= 35kg','Clients given 4G weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing >= 35kg\n Clients given 4G weighing >= 35kg\n \n 2022-06-30 13:45:24 UTC\n \n 2022-06-30 13:47: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 1664\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:45:24',4,'2022-06-30 15:47:50',4,0,NULL,NULL,NULL,'250554d7-b11e-4572-9fe8-191077c91497'),(1665,'Clients given 4H weighing 0-3.9kg','Clients given 4H weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 0-3.9kg\n Clients given 4H weighing 0-3.9kg\n \n 2022-06-30 13:49:48 UTC\n \n 2022-06-30 13:51: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 1665\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:49:48',4,'2022-06-30 15:51:33',4,0,NULL,NULL,NULL,'0681f349-aa2a-4030-8932-08fe50d977b7'),(1666,'Clients given 4H weighing 4-5.9kg','Clients given 4H weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 4-5.9kg\n Clients given 4H weighing 4-5.9kg\n \n 2022-06-30 13:50:26 UTC\n \n 2022-06-30 13:52: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 1666\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:50:26',4,'2022-06-30 15:52:13',4,0,NULL,NULL,NULL,'7d0948bd-e302-428d-be3e-c15ad93d5002'),(1667,'Clients given 4H weighing 6-9.9kg','Clients given 4H weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 6-9.9kg\n Clients given 4H weighing 6-9.9kg\n \n 2022-06-30 13:52:32 UTC\n \n 2022-06-30 13:53: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 1667\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:52:32',4,'2022-06-30 15:53:36',4,0,NULL,NULL,NULL,'ec54533d-f75a-4314-b085-4016edf73ccc'),(1668,'Clients given 4H weighing 10-13.9kg','Clients given 4H weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 10-13.9kg\n Clients given 4H weighing 10-13.9kg\n \n 2022-06-30 13:52:54 UTC\n \n 2022-06-30 13:53: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 1668\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:52:54',4,'2022-06-30 15:53:58',4,0,NULL,NULL,NULL,'306fc3f9-604f-4088-84fc-565bd360942d'),(1669,'Clients given 4H weighing 14-19.9kg','Clients given 4H weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 14-19.9kg\n Clients given 4H weighing 14-19.9kg\n \n 2022-06-30 13:54:20 UTC\n \n 2022-06-30 13:55: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 1669\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:54:20',4,'2022-06-30 15:55:40',4,0,NULL,NULL,NULL,'afa2260d-2d12-4922-8214-7321d1a7a0b2'),(1670,'Clients given 4H weighing 20-24.9kg','Clients given 4H weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 20-24.9kg\n Clients given 4H weighing 20-24.9kg\n \n 2022-06-30 13:54:47 UTC\n \n 2022-06-30 13: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 1670\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:54:47',4,'2022-06-30 15:56:07',4,0,NULL,NULL,NULL,'b12d0c96-1d85-4c87-8224-fcdcca3684ad'),(1671,'Clients given 4H weighing 25-34.9kg','Clients given 4H weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 25-34.9kg\n Clients given 4H weighing 25-34.9kg\n \n 2022-06-30 13:56:49 UTC\n \n 2022-06-30 13: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 1671\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:56:49',4,'2022-06-30 15:59:24',4,0,NULL,NULL,NULL,'c03a3023-e223-4974-82d2-f9884b64fd94'),(1672,'Clients given 4H weighing >= 35kg','Clients given 4H weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing >= 35kg\n Clients given 4H weighing >= 35kg\n \n 2022-06-30 13:57:18 UTC\n \n 2022-06-30 13:59: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 1672\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:57:18',4,'2022-06-30 15:59:06',4,0,NULL,NULL,NULL,'021ba7c8-9dde-4912-850e-7e1f90746b9c'),(1673,'Clients given 4J weighing 0-3.9kg','Clients given 4J weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 0-3.9kg\n Clients given 4J weighing 0-3.9kg\n \n 2022-06-30 14:00:30 UTC\n \n 2022-06-30 14: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 1673\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:00:30',4,'2022-06-30 16:01:59',4,0,NULL,NULL,NULL,'21e22f99-3f2f-4e4a-ac19-ea6a1fe4030a'),(1674,'Clients given 4J weighing 4-5.9kg','Clients given 4J weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 4-5.9kg\n Clients given 4J weighing 4-5.9kg\n \n 2022-06-30 14:00:54 UTC\n \n 2022-06-30 14:02: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 1674\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:00:54',4,'2022-06-30 16:02:01',4,0,NULL,NULL,NULL,'14f446ec-5d3e-43b6-ad36-6153fe3ee3e9'),(1675,'Clients given 4J weighing 6-9.9kg','Clients given 4J weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 6-9.9kg\n Clients given 4J weighing 6-9.9kg\n \n 2022-06-30 14:03:04 UTC\n \n 2022-06-30 14:04: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 1675\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:03:04',4,'2022-06-30 16:04:17',4,0,NULL,NULL,NULL,'cc3db8f2-7644-426f-9c03-2a1d48ebd7d7'),(1676,'Clients given 4J weighing 10-13.9kg','Clients given 4J weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 10-13.9kg\n Clients given 4J weighing 10-13.9kg\n \n 2022-06-30 14:03:25 UTC\n \n 2022-06-30 14:04: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 1676\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:03:25',4,'2022-06-30 16:04:39',4,0,NULL,NULL,NULL,'adc9fdd3-0019-4213-998f-ab2d235aae80'),(1677,'Clients given 4J weighing 14-19.9kg','Clients given 4J weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 14-19.9kg\n Clients given 4J weighing 14-19.9kg\n \n 2022-06-30 14:05:01 UTC\n \n 2022-06-30 14: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 1677\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:05:01',4,'2022-06-30 16:06:13',4,0,NULL,NULL,NULL,'4fc6749f-c47b-4021-8dbf-26732df08880'),(1678,'Clients given 4J weighing 20-24.9kg','Clients given 4J weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 20-24.9kg\n Clients given 4J weighing 20-24.9kg\n \n 2022-06-30 14:05:23 UTC\n \n 2022-06-30 14:06: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 1678\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:05:23',4,'2022-06-30 16:06:34',4,0,NULL,NULL,NULL,'669e5746-1eee-4811-94dd-e4c6dd949131'),(1679,'Clients given 4J weighing 25-34.9kg','Clients given 4J weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 25-34.9kg\n Clients given 4J weighing 25-34.9kg\n \n 2022-06-30 14:06:56 UTC\n \n 2022-06-30 14: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 1679\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:06:56',4,'2022-06-30 16:08:42',4,0,NULL,NULL,NULL,'78cbb142-b205-4059-89fa-70bd488a0513'),(1680,'Clients given 4J weighing >= 35kg','Clients given 4J weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing >= 35kg\n Clients given 4J weighing >= 35kg\n \n 2022-06-30 14:07:26 UTC\n \n 2022-06-30 14:09: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 1680\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:07:26',4,'2022-06-30 16:09:04',4,0,NULL,NULL,NULL,'ec90ccaa-999c-4b18-956b-50bee7c36868'),(1681,'Clients given 4L weighing 0-3.9kg','Clients given 4L weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 0-3.9kg\n Clients given 4L weighing 0-3.9kg\n \n 2022-06-30 14:09:37 UTC\n \n 2022-06-30 14:10: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 1681\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:09:37',4,'2022-06-30 16:10:48',4,0,NULL,NULL,NULL,'0e228ccb-1909-4a98-8334-89bf36d6e810'),(1682,'Clients given 4L weighing 4-5.9kg','Clients given 4L weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 4-5.9kg\n Clients given 4L weighing 4-5.9kg\n \n 2022-06-30 14:10:06 UTC\n \n 2022-06-30 14:11: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 1682\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:10:06',4,'2022-06-30 16:11:40',4,0,NULL,NULL,NULL,'d962f501-7157-4c19-9c7b-1a2a22053674'),(1683,'Clients given 4L weighing 6-9.9kg','Clients given 4L weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 6-9.9kg\n Clients given 4L weighing 6-9.9kg\n \n 2022-06-30 14:11:24 UTC\n \n 2022-06-30 14:13: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 1683\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:11:24',4,'2022-06-30 16:13:32',4,0,NULL,NULL,NULL,'16bb43f6-91a5-4e02-9627-9921460d5c68'),(1684,'Clients given 4L weighing 10-13.9kg','Clients given 4L weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 10-13.9kg\n Clients given 4L weighing 10-13.9kg\n \n 2022-06-30 14:12:51 UTC\n \n 2022-06-30 14:14: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 1684\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:12:51',4,'2022-06-30 16:14:24',4,0,NULL,NULL,NULL,'52d68e65-aa63-4c88-820e-e00bf66061ea'),(1685,'Clients given 4L weighing 14-19.9kg','Clients given 4L weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 14-19.9kg\n Clients given 4L weighing 14-19.9kg\n \n 2022-06-30 14:14:11 UTC\n \n 2022-06-30 14:15: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 1685\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:14:11',4,'2022-06-30 16:15:56',4,0,NULL,NULL,NULL,'1eb7fbd6-fa49-4ada-af7e-19424fb5a7e8'),(1686,'Clients given 4L weighing 20-24.9kg','Clients given 4L weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 20-24.9kg\n Clients given 4L weighing 20-24.9kg\n \n 2022-06-30 14:15:00 UTC\n \n 2022-06-30 14:16: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 1686\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:15:00',4,'2022-06-30 16:16:18',4,0,NULL,NULL,NULL,'d889b33a-5324-4655-965f-1fb6fdb8864d'),(1687,'Clients given 4L weighing 25-34.9kg','Clients given 4L weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 25-34.9kg\n Clients given 4L weighing 25-34.9kg\n \n 2022-06-30 14:16:41 UTC\n \n 2022-06-30 14:18: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 1687\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:16:41',4,'2022-06-30 16:18:03',4,0,NULL,NULL,NULL,'f8853175-2a1a-4d34-9a40-2d9ae44b5367'),(1688,'Clients given 4L weighing >= 35kg','Clients given 4L weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing >= 35kg\n Clients given 4L weighing >= 35kg\n \n 2022-06-30 14:17:04 UTC\n \n 2022-06-30 14:18: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 1688\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:17:04',4,'2022-06-30 16:18:34',4,0,NULL,NULL,NULL,'6cf112ca-592d-4638-8919-561aeb0e1b2e'),(1689,'Clients given 5A weighing 0-3.9kg','Clients given 5A weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 0-3.9kg\n Clients given 5A weighing 0-3.9kg\n \n 2022-07-04 07:51:16 UTC\n \n 2022-07-04 07:59: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 1689\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 13:21:16',4,'2022-07-04 13:29:19',4,0,NULL,NULL,NULL,'1e8f892d-f7dd-4c03-bae2-2b6af9a96063'),(1690,'Clients given 5A weighing 4-5.9kg','Clients given 5A weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 4-5.9kg\n Clients given 5A weighing 4-5.9kg\n \n 2022-07-04 08:01:43 UTC\n \n 2022-07-04 08: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 1690\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 13:31:43',4,'2022-07-04 13:38:34',4,0,NULL,NULL,NULL,'caef996e-3278-49a5-a46b-264db7abba88'),(1691,'Clients given 5A weighing 6-9.9kg','Clients given 5A weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 6-9.9kg\n Clients given 5A weighing 6-9.9kg\n \n 2022-07-04 08:10:17 UTC\n \n 2022-07-04 08:27: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 1691\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 13:40:17',4,'2022-07-04 13:57:38',4,0,NULL,NULL,NULL,'e035adc0-696d-46e6-8075-9ea647aea054'),(1692,'Clients given 5A weighing 10-13.9kg','Clients given 5A weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 10-13.9kg\n Clients given 5A weighing 10-13.9kg\n \n 2022-07-04 08:12:41 UTC\n \n 2022-07-04 08:29: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 1692\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 13:42:41',4,'2022-07-04 13:59:01',4,0,NULL,NULL,NULL,'ee8edb07-58b9-4884-8044-948e6bdef0a8'),(1693,'Clients given 5A weighing 14-19.9kg','Clients given 5A weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 14-19.9kg\n Clients given 5A weighing 14-19.9kg\n \n 2022-07-04 08:15:22 UTC\n \n 2022-07-04 08:30: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 1693\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 13:45:22',4,'2022-07-04 14:00:32',4,0,NULL,NULL,NULL,'91a9fa6e-69dc-4980-bb69-ff2399a6e30e'),(1694,'Clients given 5A weighing 25-34.9kg','Clients given 5A weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 25-34.9kg\n Clients given 5A weighing 25-34.9kg\n \n 2022-07-04 08:17:38 UTC\n \n 2022-07-04 08:33: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 1694\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 13:47:38',4,'2022-07-04 14:03:14',4,0,NULL,NULL,NULL,'671c4577-cc93-464c-b822-cdbee99fce15'),(1695,'Clients given 5A weighing 20-24.9kg','Clients given 5A weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 20-24.9kg\n Clients given 5A weighing 20-24.9kg\n \n 2022-07-04 08:21:33 UTC\n \n 2022-07-04 08:32: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 1695\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 13:51:33',4,'2022-07-04 14:02:01',4,0,NULL,NULL,NULL,'33f3931b-17d8-445a-8275-abe1c9c62e60'),(1696,'Clients given 5A weighing >= 35kg','Clients given 5A weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing >= 35kg\n Clients given 5A weighing >= 35kg\n \n 2022-07-04 08:22:19 UTC\n \n 2022-07-04 08:25: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 1696\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 13:52:19',4,'2022-07-04 13:55:33',4,0,NULL,NULL,NULL,'4174b385-1353-40e8-8771-820e7b8cc439'),(1697,'Clients given 5B weighing 0-3.9kg','Clients given 5B weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 0-3.9kg\n Clients given 5B weighing 0-3.9kg\n \n 2022-07-04 08:35:49 UTC\n \n 2022-07-04 08:39: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 1697\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 14:05:49',4,'2022-07-04 14:09:51',4,0,NULL,NULL,NULL,'8ccf814e-72c3-40b9-8dae-53c47231713a'),(1698,'Clients given 5B weighing 4-5.9kg','Clients given 5B weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 4-5.9kg\n Clients given 5B weighing 4-5.9kg\n \n 2022-07-04 09:11:19 UTC\n \n 2022-07-04 09:12: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 1698\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 14:41:19',4,'2022-07-04 14:42:47',4,0,NULL,NULL,NULL,'da9d3384-9203-4c29-9bb3-0064275b0bbf'),(1699,'Clients given 5B weighing 6-9.9kg','Clients given 5B weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 6-9.9kg\n Clients given 5B weighing 6-9.9kg\n \n 2022-07-04 09:12:11 UTC\n \n 2022-07-04 09:14: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 1699\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 14:42:11',4,'2022-07-04 14:44:17',4,0,NULL,NULL,NULL,'9b461cbe-5394-43f1-a3a8-5cab077d880b'),(1700,'Clients given 5B weighing 10-13.9kg','Clients given 5B weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 10-13.9kg\n Clients given 5B weighing 10-13.9kg\n \n 2022-07-04 09:13:47 UTC\n \n 2022-07-04 09:15: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 1700\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 14:43:47',4,'2022-07-04 14:45:39',4,0,NULL,NULL,NULL,'e757de08-36b9-48aa-ae1c-6e8b67f41517'),(1701,'Clients given 5B weighing 14-19.9kg','Clients given 5B weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 14-19.9kg\n Clients given 5B weighing 14-19.9kg\n \n 2022-07-04 09:17:29 UTC\n \n 2022-07-04 09:33: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 1701\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 14:47:29',4,'2022-07-04 15:03:16',4,0,NULL,NULL,NULL,'b1164742-ca14-4264-979a-53f89a268f3a'),(1702,'Clients given 5B weighing 20-24.9kg','Clients given 5B weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 20-24.9kg\n Clients given 5B weighing 20-24.9kg\n \n 2022-07-04 09:18:14 UTC\n \n 2022-07-04 09: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 1702\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 14:48:14',4,'2022-07-04 15:03:55',4,0,NULL,NULL,NULL,'37598126-d94c-4da8-bbac-1e0b9020ef33'),(1703,'Clients given 5B weighing 25-34.9kg','Clients given 5B weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 25-34.9kg\n Clients given 5B weighing 25-34.9kg\n \n 2022-07-04 09:38:26 UTC\n \n 2022-07-04 09:39: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 1703\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:08:26',4,'2022-07-04 15:09:35',4,0,NULL,NULL,NULL,'578575b5-5eaf-4487-85b6-e81f72e577e7'),(1704,'Clients given 5C weighing 0-3.9kg','Clients given 5C weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 0-3.9kg\n Clients given 5C weighing 0-3.9kg\n \n 2022-07-04 09:40:50 UTC\n \n 2022-07-04 09:46: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 1704\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:10:50',4,'2022-07-04 15:16:13',4,0,NULL,NULL,NULL,'183f7dbc-af84-4166-802d-fc168517be56'),(1705,'Clients given 5B weighing >= 35kg','Clients given 5B weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing >= 35kg\n Clients given 5B weighing >= 35kg\n \n 2022-07-04 09:41:33 UTC\n \n 2022-07-04 09: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 1705\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:11:33',4,'2022-07-04 15:15:51',4,0,NULL,NULL,NULL,'bcad7f66-5905-4cb4-820c-20b76c185df0'),(1706,'Clients given 5C weighing 4-5.9kg','Clients given 5C weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 4-5.9kg\n Clients given 5C weighing 4-5.9kg\n \n 2022-07-04 09:46:54 UTC\n \n 2022-07-04 09:48: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 1706\n COUNT\n \n \n \n \n endDate\n ${startDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:16:54',4,'2022-07-04 15:18:55',4,0,NULL,NULL,NULL,'646d055c-d02e-46d9-8af4-e8edd67a053a'),(1707,'Clients given 5C weighing 6-9.9kg','Clients given 5C weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 6-9.9kg\n Clients given 5C weighing 6-9.9kg\n \n 2022-07-04 09:47:34 UTC\n \n 2022-07-04 09:49: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 1707\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:17:34',4,'2022-07-04 15:19:45',4,0,NULL,NULL,NULL,'bff00fe0-ccdd-4e59-8a04-5daae78f609f'),(1708,'Clients given 5C weighing 6-9.9kg','Clients given 5C weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 6-9.9kg\n Clients given 5C weighing 6-9.9kg\n \n 2022-07-04 09:50:21 UTC\n \n 2022-07-04 09: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 1708\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:20:21',4,'2022-07-04 15:22:53',4,0,NULL,NULL,NULL,'a12b3ec6-868f-49da-9993-65fcea6139ce'),(1709,'Clients given 5C weighing 10-13.9kg','Clients given 5C weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 10-13.9kg\n Clients given 5C weighing 10-13.9kg\n \n 2022-07-04 09:51:17 UTC\n \n 2022-07-04 09:54: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 1709\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:21:17',4,'2022-07-04 15:24:31',4,0,NULL,NULL,NULL,'11fd5caf-00b2-4c9b-89d3-dbe43460e1b4'),(1710,'Clients given 5C weighing 14-19.9kg','Clients given 5C weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 14-19.9kg\n Clients given 5C weighing 14-19.9kg\n \n 2022-07-04 09:54:02 UTC\n \n 2022-07-04 10:19: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 1710\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:24:02',4,'2022-07-04 15:49:24',4,0,NULL,NULL,NULL,'35c1a303-9f1d-41a4-a7b2-a63222c0c0f8'),(1711,'Clients given 5C weighing 20-24.9kg','Clients given 5C weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 20-24.9kg\n Clients given 5C weighing 20-24.9kg\n \n 2022-07-04 10:20:29 UTC\n \n 2022-07-04 10:24: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 1711\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:50:29',4,'2022-07-04 15:54:33',4,0,NULL,NULL,NULL,'300ad93a-8a96-42ee-b027-15e6ea66150c'),(1712,'Clients given 5C weighing 25-34.9kg','Clients given 5C weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 25-34.9kg\n Clients given 5C weighing 25-34.9kg\n \n 2022-07-04 10:20:49 UTC\n \n 2022-07-04 10:23: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 1712\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:50:49',4,'2022-07-04 15:53:58',4,0,NULL,NULL,NULL,'2fb0cc71-47ac-4408-bb68-608d33609d53'),(1713,'Clients given 5C weighing >= 35kg','Clients given 5C weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing >= 35kg\n Clients given 5C weighing >= 35kg\n \n 2022-07-04 10:26:20 UTC\n \n 2022-07-04 10:29: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 1713\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:56:20',4,'2022-07-04 15:59:43',4,0,NULL,NULL,NULL,'731fc698-2509-4d99-9163-e08624e75417'),(1714,'Clients given 5D weighing 0-3.9kg','Clients given 5D weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 0-3.9kg\n Clients given 5D weighing 0-3.9kg\n \n 2022-07-04 10:31:02 UTC\n \n 2022-07-04 10:34: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 1714\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:01:02',4,'2022-07-04 16:04:29',4,0,NULL,NULL,NULL,'b285d939-9f51-47bd-8a6d-7f4e5d321058'),(1715,'Clients given 5D weighing 4-5.9kg','Clients given 5D weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 4-5.9kg\n Clients given 5D weighing 4-5.9kg\n \n 2022-07-04 10:36:13 UTC\n \n 2022-07-04 10:38: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 1715\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:06:13',4,'2022-07-04 16:08:50',4,0,NULL,NULL,NULL,'8c7b5eac-d68a-4dbe-b341-3417d6c7cb50'),(1716,'Clients given 5D weighing 6-9.9kg','Clients given 5D weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 6-9.9kg\n Clients given 5D weighing 6-9.9kg\n \n 2022-07-04 10:36:38 UTC\n \n 2022-07-04 10:38: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 1716\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:06:38',4,'2022-07-04 16:08:25',4,0,NULL,NULL,NULL,'f1dbcf85-e7e2-406e-ab4f-5b29a0f2dfb3'),(1717,'Clients given 5D weighing 10-13.9kg','Clients given 5D weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 10-13.9kg\n Clients given 5D weighing 10-13.9kg\n \n 2022-07-04 10:39:56 UTC\n \n 2022-07-04 10: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 1717\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:09:56',4,'2022-07-04 16:12:05',4,0,NULL,NULL,NULL,'cc9e92c9-53f2-46a4-be46-ca904d385286'),(1718,'Clients given 5D weighing 14-19.9kg','Clients given 5D weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 14-19.9kg\n Clients given 5D weighing 14-19.9kg\n \n 2022-07-04 10:40:24 UTC\n \n 2022-07-04 10:42: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 1718\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:10:24',4,'2022-07-04 16:12:36',4,0,NULL,NULL,NULL,'ea3aa469-cc4f-499c-b20f-a163afa5c116'),(1719,'Clients given 5D weighing 20-24.9kg','Clients given 5D weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 20-24.9kg\n Clients given 5D weighing 20-24.9kg\n \n 2022-07-04 10:43:39 UTC\n \n 2022-07-04 10:45: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 1719\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:13:39',4,'2022-07-04 16:15:07',4,0,NULL,NULL,NULL,'51201bc9-2e68-47b2-a264-dfe852767cbb'),(1720,'Clients given 5D weighing 25-34.9kg','Clients given 5D weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 25-34.9kg\n Clients given 5D weighing 25-34.9kg\n \n 2022-07-04 10:44:10 UTC\n \n 2022-07-04 10:46: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 1720\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:14:10',4,'2022-07-04 16:16:49',4,0,NULL,NULL,NULL,'99779a0a-4228-4d21-bc53-a4724c950f64'),(1721,'Clients given 5D weighing >= 35kg','Clients given 5D weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing >= 35kg\n Clients given 5D weighing >= 35kg\n \n 2022-07-04 10:46:20 UTC\n \n 2022-07-04 10:49: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 1721\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:16:20',4,'2022-07-04 16:19:12',4,0,NULL,NULL,NULL,'a9db689b-55c9-49a6-bf7b-f841503b81d4'),(1722,'Clients given 5E weighing 0-3.9kg','Clients given 5E weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 0-3.9kg\n Clients given 5E weighing 0-3.9kg\n \n 2022-07-04 10:49:03 UTC\n \n 2022-07-04 10: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 1722\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:19:03',4,'2022-07-04 16:24:57',4,0,NULL,NULL,NULL,'98825a71-acf0-4a06-b318-1dfbc4bc85e8'),(1723,'Clients given 5E weighing 4-5.9kg','Clients given 5E weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 4-5.9kg\n Clients given 5E weighing 4-5.9kg\n \n 2022-07-04 10:50:24 UTC\n \n 2022-07-04 10: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 1723\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:20:24',4,'2022-07-04 16:23:38',4,0,NULL,NULL,NULL,'09876d38-7d00-460f-a95d-f1d084f84cb0'),(1724,'Clients given 5E weighing 6-9.9kg','Clients given 5E weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 6-9.9kg\n Clients given 5E weighing 6-9.9kg\n \n 2022-07-04 10:55:45 UTC\n \n 2022-07-04 10:59: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 1724\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:25:45',4,'2022-07-04 16:29:01',4,0,NULL,NULL,NULL,'d95839a2-da76-4d9f-9dde-6ef33f9d3c7d'),(1725,'Clients given 5E weighing 10-13.9kg','Clients given 5E weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 10-13.9kg\n Clients given 5E weighing 10-13.9kg\n \n 2022-07-04 10:56:27 UTC\n \n 2022-07-04 11:04: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 1725\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:26:27',4,'2022-07-04 16:34:36',4,0,NULL,NULL,NULL,'c0a9a74f-b14c-42fb-87bc-710bd652916c'),(1726,'Clients given 5E weighing 14-19.9kg','Clients given 5E weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 14-19.9kg\n Clients given 5E weighing 14-19.9kg\n \n 2022-07-04 11:00:36 UTC\n \n 2022-07-04 11:07: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 1726\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:30:36',4,'2022-07-04 16:37:08',4,0,NULL,NULL,NULL,'29478b1e-23c8-4fa0-a17e-9f3c11e801af'),(1727,'Clients given 5E weighing 20-24.9kg','Clients given 5E weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 20-24.9kg\n Clients given 5E weighing 20-24.9kg\n \n 2022-07-04 11:06:35 UTC\n \n 2022-07-04 11:08: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 1727\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:36:35',4,'2022-07-04 16:38:57',4,0,NULL,NULL,NULL,'0a71c7f2-39c8-4d46-bdb3-847b616997b6'),(1728,'Clients given 5E weighing 25-34.9kg','Clients given 5E weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 25-34.9kg\n Clients given 5E weighing 25-34.9kg\n \n 2022-07-04 11:09:38 UTC\n \n 2022-07-04 11:12: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 1728\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:39:38',4,'2022-07-04 16:42:02',4,0,NULL,NULL,NULL,'f20e7d1a-0f66-4fb8-a254-11720f9fcdb4'),(1729,'Clients given 5E weighing >= 35kg','Clients given 5E weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing >= 35kg\n Clients given 5E weighing >= 35kg\n \n 2022-07-04 11:10:10 UTC\n \n 2022-07-04 11:11: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 1729\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:40:10',4,'2022-07-04 16:41:28',4,0,NULL,NULL,NULL,'6c8300f9-3327-46f5-b538-5926daf7f3e9'),(1730,'Clients given 5F weighing 0-3.9kg','Clients given 5F weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 0-3.9kg\n Clients given 5F weighing 0-3.9kg\n \n 2022-07-04 11:12:43 UTC\n \n 2022-07-04 11:16: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 1730\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:42:43',4,'2022-07-04 16:46:11',4,0,NULL,NULL,NULL,'cc140697-6404-4bfa-927a-1e331e05a771'),(1731,'Clients given 5F weighing 4-5.9kg','Clients given 5F weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 4-5.9kg\n Clients given 5F weighing 4-5.9kg\n \n 2022-07-04 11:15:42 UTC\n \n 2022-07-04 11: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 1731\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:45:42',4,'2022-07-04 16:47:37',4,0,NULL,NULL,NULL,'feee080e-df6e-4d55-a631-a5b8e6561be8'),(1732,'Clients given 5F weighing 6-9.9kg','Clients given 5F weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 6-9.9kg\n Clients given 5F weighing 6-9.9kg\n \n 2022-07-04 11:16:51 UTC\n \n 2022-07-04 11:20: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 1732\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:46:51',4,'2022-07-04 16:50:54',4,0,NULL,NULL,NULL,'fefc7c1d-f181-415a-b896-9ef303b4ce6a'),(1733,'Clients given 5F weighing 10-13.9kg','Clients given 5F weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 10-13.9kg\n Clients given 5F weighing 10-13.9kg\n \n 2022-07-04 11:19:35 UTC\n \n 2022-07-04 11:21: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 1733\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:49:35',4,'2022-07-04 16:51:36',4,0,NULL,NULL,NULL,'cc52bd93-49e7-488c-9706-669f6401eb7a'),(1734,'Clients given 5F weighing 14-19.9kg','Clients given 5F weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 14-19.9kg\n Clients given 5F weighing 14-19.9kg\n \n 2022-07-04 11:27:47 UTC\n \n 2022-07-04 11:30: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 1734\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:57:47',4,'2022-07-04 17:00:51',4,0,NULL,NULL,NULL,'a1b3f036-8f11-463c-906f-0907c8bb3168'),(1735,'Clients given 5F weighing 20-24.9kg','Clients given 5F weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 20-24.9kg\n Clients given 5F weighing 20-24.9kg\n \n 2022-07-04 11:28:06 UTC\n \n 2022-07-04 11:31: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 1735\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:58:06',4,'2022-07-04 17:01:26',4,0,NULL,NULL,NULL,'545d0307-0065-48ef-b35d-db0b97d6f0a4'),(1736,'Clients given 5F weighing 25-34.9kg','Clients given 5F weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 25-34.9kg\n Clients given 5F weighing 25-34.9kg\n \n 2022-07-04 11:32:18 UTC\n \n 2022-07-04 11:34: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 1736\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:02:18',4,'2022-07-04 17:04:20',4,0,NULL,NULL,NULL,'a3cc0250-e3f5-4b02-a569-d5737c7c2ca2'),(1737,'Clients given 5F weighing >= 35kg','Clients given 5F weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing >= 35kg\n Clients given 5F weighing >= 35kg\n \n 2022-07-04 11:32:59 UTC\n \n 2022-07-04 11:34: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 1737\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:02:59',4,'2022-07-04 17:04:45',4,0,NULL,NULL,NULL,'ff867f63-d45f-4ffc-8378-22a72111492b'),(1738,'Clients given 5G weighing 0-3.9kg','Clients given 5G weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 0-3.9kg\n Clients given 5G weighing 0-3.9kg\n \n 2022-07-04 11:37:11 UTC\n \n 2022-07-04 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 1738\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:07:11',4,'2022-07-04 17:09:08',4,0,NULL,NULL,NULL,'b5725eac-2a7a-4f4b-be0b-670c5edae46f'),(1739,'Clients given 5G weighing 4-5.9kg','Clients given 5G weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 4-5.9kg\n Clients given 5G weighing 4-5.9kg\n \n 2022-07-04 11:38:21 UTC\n \n 2022-07-04 11:40: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 1739\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:08:21',4,'2022-07-04 17:10:28',4,0,NULL,NULL,NULL,'01b5a831-a97a-473d-9cab-171aed11937a'),(1740,'Clients given 5G weighing 6-9.9kg','Clients given 5G weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 6-9.9kg\n Clients given 5G weighing 6-9.9kg\n \n 2022-07-04 11:40:56 UTC\n \n 2022-07-04 11:42: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 1740\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:10:56',4,'2022-07-04 17:12:46',4,0,NULL,NULL,NULL,'b35556af-d5de-4740-8d7d-ee2c7415f2aa'),(1741,'Clients given 5G weighing 10-13.9kg','Clients given 5G weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 10-13.9kg\n Clients given 5G weighing 10-13.9kg\n \n 2022-07-04 11:41:26 UTC\n \n 2022-07-04 11:43: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 1741\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:11:26',4,'2022-07-04 17:13:31',4,0,NULL,NULL,NULL,'fecb7060-8111-4db9-aa13-9355bfe19034'),(1742,'Clients given 5G weighing 14-19.9kg','Clients given 5G weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 14-19.9kg\n Clients given 5G weighing 14-19.9kg\n \n 2022-07-04 11:44:52 UTC\n \n 2022-07-04 11:47: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 1742\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:14:52',4,'2022-07-04 17:17:38',4,0,NULL,NULL,NULL,'edcea1e9-f4fe-459c-a9a5-99dc5b454f6b'),(1743,'Clients given 5G weighing 20-24.9kg','Clients given 5G weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 20-24.9kg\n Clients given 5G weighing 20-24.9kg\n \n 2022-07-04 11:45:28 UTC\n \n 2022-07-04 11:47: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 1743\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:15:28',4,'2022-07-04 17:17:23',4,0,NULL,NULL,NULL,'d624256f-ee53-49de-b806-e54f0f885165'),(1744,'Clients given 5G weighing 25-34.9kg','Clients given 5G weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 25-34.9kg\n Clients given 5G weighing 25-34.9kg\n \n 2022-07-04 11:48:46 UTC\n \n 2022-07-06 09:16: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 1744\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 11:48:46',4,'2022-07-06 09:16:23',4,0,NULL,NULL,NULL,'2fdbe8de-90ef-4198-8960-6d195608e255'),(1745,'Clients given 5G weighing >= 35kg','Clients given 5G weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing >= 35kg\n Clients given 5G weighing >= 35kg\n \n 2022-07-04 11:49:49 UTC\n \n 2022-07-04 11:51: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 1745\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:19:49',4,'2022-07-04 17:21:52',4,0,NULL,NULL,NULL,'477dc5ab-12a7-4553-b65d-57ced1093ae7'),(1746,'Clients given 5G weighing 0-3.9kg','Clients given 5G weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 0-3.9kg\n Clients given 5G weighing 0-3.9kg\n \n 2022-07-04 11:52:26 UTC\n \n 2022-07-04 11:55: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 1746\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:22:26',4,'2022-07-04 17:25:43',4,0,NULL,NULL,NULL,'b30dd237-ce5e-4eb4-8c3e-e4522f1fc695'),(1747,'Clients given 5G weighing 4-5.9kg','Clients given 5G weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 4-5.9kg\n Clients given 5G weighing 4-5.9kg\n \n 2022-07-04 11:53:47 UTC\n \n 2022-07-04 11:56: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 1747\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:23:47',4,'2022-07-04 17:26:37',4,0,NULL,NULL,NULL,'8e235e40-e811-4db9-82c2-ab1b5d2965f9'),(1748,'Clients given 5G weighing 6-9.9kg','Clients given 5G weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 6-9.9kg\n Clients given 5G weighing 6-9.9kg\n \n 2022-07-04 11:57:59 UTC\n \n 2022-07-04 12: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 1748\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:27:59',4,'2022-07-04 17:30:12',4,0,NULL,NULL,NULL,'b0a0a091-97ba-49d0-9845-f10070dd4ea3'),(1749,'Clients given 5G weighing 10-13.9kg','Clients given 5G weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 10-13.9kg\n Clients given 5G weighing 10-13.9kg\n \n 2022-07-04 11:58:53 UTC\n \n 2022-07-04 12:00: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 1749\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:28:53',4,'2022-07-04 17:30:48',4,0,NULL,NULL,NULL,'3d826ce1-96c8-4e57-892d-c097e4ac9ac5'),(1750,'Clients given 5G weighing 14-19.9kg','Clients given 5G weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 14-19.9kg\n Clients given 5G weighing 14-19.9kg\n \n 2022-07-04 12:03:51 UTC\n \n 2022-07-04 12:08: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 1750\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:33:51',4,'2022-07-04 17:38:23',4,0,NULL,NULL,NULL,'79890495-f468-4d64-b519-756630352b5d'),(1751,'Clients given 5G weighing 20-24.9kg','Clients given 5G weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 20-24.9kg\n Clients given 5G weighing 20-24.9kg\n \n 2022-07-04 12:04:50 UTC\n \n 2022-07-04 18:39: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 1751\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:34:50',4,'2022-07-05 00:09:28',4,0,NULL,NULL,NULL,'d06ae952-edbf-4c3e-b3a8-1c4ee70886fc'),(1752,' Clients given 5G weighing 25-29.9kg',' Clients given 5G weighing 25-29.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 25-29.9kg\n Clients given 5G weighing 25-29.9kg\n \n 2022-07-04 18:44:18 UTC\n \n 2022-07-04 18:47: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 1752\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:14:18',4,'2022-07-05 00:17:20',4,0,NULL,NULL,NULL,'ad3c3764-3438-43a7-ade5-98458af16de5'),(1753,' Clients given 5G weighing >= 35kg',' Clients given 5G weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing >= 35kg\n Clients given 5G weighing >= 35kg\n \n 2022-07-04 18:47:57 UTC\n \n 2022-07-04 18:49: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 1753\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:17:57',4,'2022-07-05 00:19:45',4,0,NULL,NULL,NULL,'5c731dbc-ddd2-4a58-9e69-c112f74d40a7'),(1754,' Clients given 5H weighing 0-3.9kg',' Clients given 5H weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 0-3.9kg\n Clients given 5H weighing 0-3.9kg\n \n 2022-07-04 18:49:18 UTC\n \n 2022-07-04 18:53: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 1754\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:19:18',4,'2022-07-05 00:23:27',4,0,NULL,NULL,NULL,'76ca732d-65f9-4ec3-8c5c-41d7503ed512'),(1755,' Clients given 5H weighing 4-5.9kg',' Clients given 5H weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 4-5.9kg\n Clients given 5H weighing 4-5.9kg\n \n 2022-07-04 18:54:29 UTC\n \n 2022-07-04 18:55: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 1755\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:24:29',4,'2022-07-05 00:25:53',4,0,NULL,NULL,NULL,'75354bc7-40ec-489e-a13a-5b0de9d609cd'),(1756,' Clients given 5H weighing 6-9.9kg',' Clients given 5H weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 6-9.9kg\n Clients given 5H weighing 6-9.9kg\n \n 2022-07-04 18:55:07 UTC\n \n 2022-07-04 18: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 1756\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:25:07',4,'2022-07-05 00:28:07',4,0,NULL,NULL,NULL,'4c27c57e-78ec-4934-837f-d52f59a8e263'),(1757,' Clients given 5H weighing 10-13.9kg',' Clients given 5H weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 10-13.9kg\n Clients given 5H weighing 10-13.9kg\n \n 2022-07-04 18:57:10 UTC\n \n 2022-07-04 19:05: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 1757\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:27:10',4,'2022-07-05 00:35:15',4,0,NULL,NULL,NULL,'10ee2cc4-a8c0-46c7-8b26-2c69eafd6aed'),(1758,' Clients given 5H weighing 14-19.9kg',' Clients given 5H weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 14-19.9kg\n Clients given 5H weighing 14-19.9kg\n \n 2022-07-04 18:58:51 UTC\n \n 2022-07-04 19:01: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 1758\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:28:51',4,'2022-07-05 00:31:57',4,0,NULL,NULL,NULL,'bfd4191f-c556-41df-8f09-970ece8eb883'),(1759,' Clients given 5H weighing 20-24.9kg',' Clients given 5H weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 20-24.9kg\n Clients given 5H weighing 20-24.9kg\n \n 2022-07-04 19:02:44 UTC\n \n 2022-07-04 19:03: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 1759\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:32:44',4,'2022-07-05 00:33:54',4,0,NULL,NULL,NULL,'3118f852-4fd1-4807-abfc-6f4d8a4b34e3'),(1760,' Clients given 5H weighing 25-34.9kg',' Clients given 5H weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 25-34.9kg\n Clients given 5H weighing 25-34.9kg\n \n 2022-07-04 19:04:45 UTC\n \n 2022-07-04 19:07: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 1760\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:34:45',4,'2022-07-05 00:37:04',4,0,NULL,NULL,NULL,'443efbd3-a0a9-473a-8408-e57b58477156'),(1761,' Clients given 5H weighing >= 35kg',' Clients given 5H weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing >= 35kg\n Clients given 5H weighing >= 35kg\n \n 2022-07-04 19:06:06 UTC\n \n 2022-07-04 19:07: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 1761\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:36:06',4,'2022-07-05 00:37:27',4,0,NULL,NULL,NULL,'89320a1f-49b4-464e-8a37-21748419ed81'),(1762,' Clients given 6A weighing 0-3.9kg',' Clients given 6A weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 0-3.9kg\n Clients given 6A weighing 0-3.9kg\n \n 2022-07-04 19:08:02 UTC\n \n 2022-07-04 19:09: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 1762\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:38:02',4,'2022-07-05 00:39:31',4,0,NULL,NULL,NULL,'f0cdda8e-9894-4125-b1c0-014ccc6ad7ea'),(1763,' Clients given 6A weighing 4-5.9kg',' Clients given 6A weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 4-5.9kg\n Clients given 6A weighing 4-5.9kg\n \n 2022-07-04 19:08:26 UTC\n \n 2022-07-04 19:09: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 1763\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:38:26',4,'2022-07-05 00:39:50',4,0,NULL,NULL,NULL,'5701682a-a88c-46a8-957a-3322894a6e43'),(1764,' Clients given 6A weighing 6-9.9kg',' Clients given 6A weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 6-9.9kg\n Clients given 6A weighing 6-9.9kg\n \n 2022-07-04 19:10:14 UTC\n \n 2022-07-04 19:11: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 1764\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:40:14',4,'2022-07-05 00:41:50',4,0,NULL,NULL,NULL,'92f27e6f-6178-4e65-b055-798f3dd1e1ae'),(1765,' Clients given 6A weighing 10-13.9kg',' Clients given 6A weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 10-13.9kg\n Clients given 6A weighing 10-13.9kg\n \n 2022-07-04 19:10:49 UTC\n \n 2022-07-04 19:12: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 1765\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:40:49',4,'2022-07-05 00:42:19',4,0,NULL,NULL,NULL,'a74e222c-96c6-45f8-83e7-3ce0d50cc83c'),(1766,' Clients given 6A weighing 14-19.9kg',' Clients given 6A weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 14-19.9kg\n Clients given 6A weighing 14-19.9kg\n \n 2022-07-04 19:12:45 UTC\n \n 2022-07-04 19:14: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 1766\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:42:45',4,'2022-07-05 00:44:57',4,0,NULL,NULL,NULL,'79e9b5db-636c-4afb-8291-cb558667ebd5'),(1767,' Clients given 6A weighing 20-24.9kg',' Clients given 6A weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 20-24.9kg\n Clients given 6A weighing 20-24.9kg\n \n 2022-07-04 19:13:20 UTC\n \n 2022-07-04 19:15: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 1767\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:43:20',4,'2022-07-05 00:45:14',4,0,NULL,NULL,NULL,'11eeec05-8a04-4f44-bc0c-dddb88b8270d'),(1768,' Clients given 6A weighing 25-34.9kg',' Clients given 6A weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 25-34.9kg\n Clients given 6A weighing 25-34.9kg\n \n 2022-07-04 19:13:46 UTC\n \n 2022-07-04 19:15: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 1768\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:43:46',4,'2022-07-05 00:45:35',4,0,NULL,NULL,NULL,'23c30258-a527-4c1e-92b8-c3d7310c7c49'),(1769,' Clients given 6A weighing >= 35kg',' Clients given 6A weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing >= 35kg\n Clients given 6A weighing >= 35kg\n \n 2022-07-04 19:16:05 UTC\n \n 2022-07-04 19:18: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 1769\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:46:05',4,'2022-07-05 00:48:21',4,0,NULL,NULL,NULL,'eac739c5-ff7a-4169-a6c2-faba753958df'),(1770,' Clients given 6B weighing 0-3.9kg',' Clients given 6B weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 0-3.9kg\n Clients given 6B weighing 0-3.9kg\n \n 2022-07-04 19:16:33 UTC\n \n 2022-07-04 19: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 1770\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:46:33',4,'2022-07-05 00:48:05',4,0,NULL,NULL,NULL,'6e8cb9ab-5663-4da1-9c67-9188bf5ce4c6'),(1771,' Clients given 6B weighing 4-5.9kg',' Clients given 6B weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 4-5.9kg\n Clients given 6B weighing 4-5.9kg\n \n 2022-07-04 19:16:56 UTC\n \n 2022-07-04 19:18: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 1771\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:46:56',4,'2022-07-05 00:48:41',4,0,NULL,NULL,NULL,'6e7f8b89-d2bb-42a4-8b0d-687950bfd3a8'),(1772,' Clients given 6B weighing 6-9.9kg',' Clients given 6B weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 6-9.9kg\n Clients given 6B weighing 6-9.9kg\n \n 2022-07-04 19:19:08 UTC\n \n 2022-07-04 19:22: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 1772\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:49:08',4,'2022-07-05 00:52:03',4,0,NULL,NULL,NULL,'4ccea0f3-80d7-4b3f-850f-93985538cfeb'),(1773,' Clients given 6B weighing 10-13.9kg',' Clients given 6B weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 10-13.9kg\n Clients given 6B weighing 10-13.9kg\n \n 2022-07-04 19:19:37 UTC\n \n 2022-07-04 19:22: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 1773\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:49:37',4,'2022-07-05 00:52:18',4,0,NULL,NULL,NULL,'3c303fcf-f9db-4e5f-8e9e-33df86616930'),(1774,' Clients given 6B weighing 14-19.9kg',' Clients given 6B weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 14-19.9kg\n Clients given 6B weighing 14-19.9kg\n \n 2022-07-04 19:20:09 UTC\n \n 2022-07-04 19: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 1774\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:50:09',4,'2022-07-05 00:54:44',4,0,NULL,NULL,NULL,'551ea342-168d-4089-834b-dab745648722'),(1775,' Clients given 6B weighing 20-24.9kg',' Clients given 6B weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 20-24.9kg\n Clients given 6B weighing 20-24.9kg\n \n 2022-07-04 19:20:32 UTC\n \n 2022-07-04 19:23: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 1775\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:50:32',4,'2022-07-05 00:53:03',4,0,NULL,NULL,NULL,'42e304a1-3961-4344-ae32-2348b7a5b81a'); -INSERT INTO `serialized_object` VALUES (1776,' Clients given 6B weighing 25-34.9kg',' Clients given 6B weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 25-34.9kg\n Clients given 6B weighing 25-34.9kg\n \n 2022-07-04 19:23:47 UTC\n \n 2022-07-04 19:27: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 1776\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:53:47',4,'2022-07-05 00:57:17',4,0,NULL,NULL,NULL,'70621294-d632-4b66-8f10-0343433b8267'),(1777,' Clients given 6B weighing >= 35kg',' Clients given 6B weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing >= 35kg\n Clients given 6B weighing >= 35kg\n \n 2022-07-04 19:24:19 UTC\n \n 2022-07-04 19:27: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 1777\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:54:19',4,'2022-07-05 00:57:33',4,0,NULL,NULL,NULL,'ed32ff5b-41ed-4933-a39e-bc4fb685b9eb'),(1778,'Clients given 6C weighing 0-3.9kg','Clients given 6C weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 0-3.9kg\n Clients given 6C weighing 0-3.9kg\n \n 2022-07-05 06:03:11 UTC\n \n 2022-07-05 06:05: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 1778\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:33:11',4,'2022-07-05 11:35:26',4,0,NULL,NULL,NULL,'7708c697-6d7d-42e7-aba6-613e36081fab'),(1779,'Clients given 6C weighing 4-5.9kg','Clients given 6C weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 4-5.9kg\n Clients given 6C weighing 6-9.9kg\n \n 2022-07-05 06:03:33 UTC\n \n 2022-07-05 06:09: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 1779\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:33:33',4,'2022-07-05 11:39:04',4,0,NULL,NULL,NULL,'95504660-becd-4eff-a280-5aa869762885'),(1780,'Clients given 6C weighing 6-9.9kg','Clients given 6C weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 6-9.9kg\n Clients given 6C weighing 6-9.9kg\n \n 2022-07-05 06:03:55 UTC\n \n 2022-07-05 06:07: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 1780\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:33:55',4,'2022-07-05 11:37:47',4,0,NULL,NULL,NULL,'d3ba1e90-03ce-4af3-8b68-9e4bb86a2fda'),(1781,'Clients given 6C weighing 10-13.9kg','Clients given 6C weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 10-13.9kg\n Clients given 6C weighing 10-13.9kg\n \n 2022-07-05 06:09:31 UTC\n \n 2022-07-05 06:12:33 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 1781\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:39:31',4,'2022-07-05 11:42:33',4,0,NULL,NULL,NULL,'bd61f262-344c-4834-846b-dbfd4b8f8454'),(1782,'Clients given 6C weighing 14-19.9kg','Clients given 6C weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 14-19.9kg\n Clients given 6C weighing 14-19.9kg\n \n 2022-07-05 06:11:03 UTC\n \n 2022-07-05 06: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 1782\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:41:03',4,'2022-07-05 11:44:18',4,0,NULL,NULL,NULL,'ef452600-16ec-4d05-bf02-a2f5da8c503d'),(1783,'Clients given 6C weighing 20-24.9kg','Clients given 6C weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 20-24.9kg\n Clients given 6C weighing 20-24.9kg\n \n 2022-07-05 06:12:09 UTC\n \n 2022-07-05 06:14: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 1783\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:42:09',4,'2022-07-05 11:44:44',4,0,NULL,NULL,NULL,'84b7e946-ef4b-498c-aa99-a7469d841d89'),(1784,'Clients given 6C weighing 25-34.9kg','Clients given 6C weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 25-34.9kg\n Clients given 6C weighing 25-34.9kg\n \n 2022-07-05 06:13:57 UTC\n \n 2022-07-05 06: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 1784\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:43:57',4,'2022-07-05 11:47:03',4,0,NULL,NULL,NULL,'d0662ec5-9909-46a1-8d42-4f13c5e08f54'),(1785,'Clients given 6C weighing >= 35kg','Clients given 6C weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing >= 35kg\n Clients given 6C weighing >= 35kg\n \n 2022-07-05 06:17:43 UTC\n \n 2022-07-05 06:20: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 1785\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:47:43',4,'2022-07-05 11:50:43',4,0,NULL,NULL,NULL,'e469295b-caa7-4154-b5ac-e2d0a7042d5b'),(1786,'Clients given 6D weighing 0-3.9kg','Clients given 6D weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 0-3.9kg\n Clients given 6D weighing 0-3.9kg\n \n 2022-07-05 06:18:16 UTC\n \n 2022-07-05 06:19: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 1786\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:48:16',4,'2022-07-05 11:49:53',4,0,NULL,NULL,NULL,'a6985c5b-86f8-4647-86ea-ddd69097681e'),(1787,'Clients given 6D weighing 4-5.9kg','Clients given 6D weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 4-5.9kg\n Clients given 6D weighing 4-5.9kg\n \n 2022-07-05 06:18:43 UTC\n \n 2022-07-05 06:20: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 1787\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:48:43',4,'2022-07-05 11:50:24',4,0,NULL,NULL,NULL,'3eec1d07-6d91-43dd-a942-24d23e4a0f9c'),(1788,'Clients given 6D weighing 6-9.9kg','Clients given 6D weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 6-9.9kg\n Clients given 6D weighing 6-9.9kg\n \n 2022-07-05 06:21:17 UTC\n \n 2022-07-05 06:22: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 1788\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:51:17',4,'2022-07-05 11:52:45',4,0,NULL,NULL,NULL,'37509f55-cbd9-4096-8522-1e7918b1a48c'),(1789,'Clients given 6D weighing 10-13.9kg','Clients given 6D weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 10-13.9kg\n Clients given 6D weighing 10-13.9kg\n \n 2022-07-05 06:21:34 UTC\n \n 2022-07-05 06:23: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 1789\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:51:34',4,'2022-07-05 11:53:04',4,0,NULL,NULL,NULL,'477311cf-0367-47e1-9717-4732fc0752f0'),(1790,'Clients given 6D weighing 14-19.9kg','Clients given 6D weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 14-19.9kg\n Clients given 6D weighing 14-19.9kg\n \n 2022-07-05 06:21:55 UTC\n \n 2022-07-05 06: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 1790\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:51:55',4,'2022-07-05 11:53:21',4,0,NULL,NULL,NULL,'62232334-aa48-4e29-92fc-c4f931bcfb01'),(1791,'Clients given 6D weighing 20-24.9kg','Clients given 6D weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 20-24.9kg\n Clients given 6D weighing 20-24.9kg\n \n 2022-07-05 06:23:43 UTC\n \n 2022-07-05 06:25: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 1791\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:53:43',4,'2022-07-05 11:55:33',4,0,NULL,NULL,NULL,'8b171cf1-4052-49f3-9b28-76161872f1ac'),(1792,'Clients given 6D weighing 25-34.9kg','Clients given 6D weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 25-34.9kg\n Clients given 6D weighing 25-34.9kg\n \n 2022-07-05 06:24:03 UTC\n \n 2022-07-05 06:25: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 1792\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:54:03',4,'2022-07-05 11:55:47',4,0,NULL,NULL,NULL,'20d6a8c0-12ee-420c-a3f6-22d2e7a829bd'),(1793,'Clients given 6D weighing >= 35kg','Clients given 6D weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing >= 35kg\n Clients given 6D weighing >= 35kg\n \n 2022-07-05 06:24:35 UTC\n \n 2022-07-05 06:26: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 1793\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:54:35',4,'2022-07-05 11:56:11',4,0,NULL,NULL,NULL,'41d104fe-8277-4caa-b55e-07ea346801a7'),(1794,'Clients given 6E weighing 0-3.9 kg','Clients given 6E weighing 0-3.9 kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 0-3.9 kg\n Clients given 6E weighing 0-3.9 kg\n \n 2022-07-05 06:27:58 UTC\n \n 2022-07-05 06:30: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 1794\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:57:58',4,'2022-07-05 12:00:43',4,0,NULL,NULL,NULL,'ddcdfef8-c5fd-4bd2-9963-4d5d48702f57'),(1795,'Clients given 6E weighing 4-5.9 kg','Clients given 6E weighing 4-5.9 kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 4-5.9 kg\n Clients given 6E weighing 4-5.9 kg\n \n 2022-07-05 06:28:17 UTC\n \n 2022-07-05 06:32: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 1795\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:58:17',4,'2022-07-05 12:02:01',4,0,NULL,NULL,NULL,'52757686-f3a7-4d53-84bb-76aea347f4d3'),(1796,'Clients given 6E weighing 6-9.9 kg','Clients given 6E weighing 6-9.9 kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 6-9.9 kg\n Clients given 6E weighing 6-9.9 kg\n \n 2022-07-05 06:30:03 UTC\n \n 2022-07-05 06: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 1796\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','2022-07-05 12:00:03',4,'2022-07-05 12:01:15',4,0,NULL,NULL,NULL,'d0682189-7d23-4c17-9648-ae39ea0f6916'),(1797,'Clients given 6E weighing 10-13.9 kg','Clients given 6E weighing 10-13.9 kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 10-13.9 kg\n Clients given 6E weighing 10-13.9 kg\n \n 2022-07-05 06:32:34 UTC\n \n 2022-07-05 06:34: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 1797\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:02:34',4,'2022-07-05 12:04:30',4,0,NULL,NULL,NULL,'ad8a6b3c-88dd-4328-b042-076242f1ce54'),(1798,'Clients given 6E weighing 14-19.9 kg','Clients given 6E weighing 14-19.9 kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 14-19.9 kg\n Clients given 6E weighing 14-19.9 kg\n \n 2022-07-05 06:33:01 UTC\n \n 2022-07-05 06: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 1798\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:03:01',4,'2022-07-05 12:04:51',4,0,NULL,NULL,NULL,'d58c1b55-d21c-497a-b201-c1f544c8264c'),(1799,'Clients given 6E weighing 20-24.9 kg','Clients given 6E weighing 20-24.9 kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 20-24.9 kg\n Clients given 6E weighing 20-24.9 kg\n \n 2022-07-05 06:33:24 UTC\n \n 2022-07-05 06:35: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 1799\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:03:24',4,'2022-07-05 12:05:10',4,0,NULL,NULL,NULL,'e38de12c-6c72-4188-a8b7-b6d912e7baf2'),(1800,'Clients given 6E weighing 25-34.9 kg','Clients given 6E weighing 25-34.9 kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 25-34.9 kg\n Clients given 6E weighing 25-34.9 kg\n \n 2022-07-05 06:35:31 UTC\n \n 2022-07-05 06:37: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 1800\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:05:31',4,'2022-07-05 12:07:03',4,0,NULL,NULL,NULL,'24def27b-738c-424e-b397-689a9fc28dd0'),(1801,'Clients given 6E weighing >= 35 kg','Clients given 6E weighing >= 35 kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing >= 35 kg\n Clients given 6E weighing >= 35 kg\n \n 2022-07-05 06:35:59 UTC\n \n 2022-07-05 06:37: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 1801\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:05:59',4,'2022-07-05 12:07:19',4,0,NULL,NULL,NULL,'bc732e0d-7aa7-412d-855c-76442487b9c9'),(1802,'Clients given 6F weighing 4-5.9kg','Clients given 6F weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 4-5.9kg\n Clients given 6F weighing 4-5.9kg\n \n 2022-07-05 06:38:03 UTC\n \n 2022-07-05 06:42: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 1802\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:08:03',4,'2022-07-05 12:12:09',4,0,NULL,NULL,NULL,'31aaf13e-0c70-472d-9d6f-8d288c6545d7'),(1803,'Clients given 6F weighing 0-3.9kg','Clients given 6F weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 0-3.9kg\n Clients given 6F weighing 0-3.9kg\n \n 2022-07-05 06:38:38 UTC\n \n 2022-07-05 06:43: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 1803\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:08:38',4,'2022-07-05 12:13:27',4,0,NULL,NULL,NULL,'ec58cc67-3866-4031-a385-d5f40bf5fa80'),(1804,'Clients given 6F weighing 6-9.9kg','Clients given 6F weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 6-9.9kg\n Clients given 6F weighing 6-9.9kg\n \n 2022-07-05 06:40:34 UTC\n \n 2022-07-05 06:42: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 1804\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','2022-07-05 12:10:34',4,'2022-07-05 12:12:24',4,0,NULL,NULL,NULL,'ece7781b-8125-44f0-8189-6f4f66258b2c'),(1805,'Clients given 6F weighing 10-13.9kg','Clients given 6F weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 10-13.9kg\n Clients given 6F weighing 10-13.9kg\n \n 2022-07-05 06:44:04 UTC\n \n 2022-07-05 06:47: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 1805\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:14:04',4,'2022-07-05 12:17:25',4,0,NULL,NULL,NULL,'6cd6003e-fd2a-4acd-acbf-8025ed274332'),(1806,'Clients given 6F weighing 14-19.9kg','Clients given 6F weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 14-19.9kg\n Clients given 6F weighing 14-19.9kg\n \n 2022-07-05 06:44:30 UTC\n \n 2022-07-05 06:50: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 1806\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:14:30',4,'2022-07-05 12:20:01',4,0,NULL,NULL,NULL,'c465345e-8ab1-45d7-972a-d39b87dd1ade'),(1807,'Clients given 6F weighing 20-24.9kg','Clients given 6F weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 20-24.9kg\n Clients given 6F weighing 20-24.9kg\n \n 2022-07-05 06:44:51 UTC\n \n 2022-07-05 06: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 1807\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:14:51',4,'2022-07-05 12:16:42',4,0,NULL,NULL,NULL,'383ecc01-a8e6-42b4-83f3-eb9c2e48386b'),(1808,'Clients given 6F weighing 25-34.9kg','Clients given 6F weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 25-34.9kg\n Clients given 6F weighing 25-34.9kg\n \n 2022-07-05 06:49:35 UTC\n \n 2022-07-05 06: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 1808\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:19:35',4,'2022-07-05 12:24:29',4,0,NULL,NULL,NULL,'bacab6c2-b1d6-4a10-9f0d-ffb24844bae5'),(1809,'Clients given 6F weighing >= 35kg','Clients given 6F weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing >= 35kg\n Clients given 6F weighing >= 35kg\n \n 2022-07-05 06:53:17 UTC\n \n 2022-07-05 06: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 1809\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:23:17',4,'2022-07-05 12:26:41',4,0,NULL,NULL,NULL,'2614b81d-6441-4ee3-b4a7-a15f3ba36ace'),(1810,'Children ARV Regimen_2ndLine_2022','Children ARV Regimen_2ndLine','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_2022\n Children ARV Regimen_2ndLine\n \n 2022-07-06 07:16:05 UTC\n \n 2022-07-06 10:13: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 1810\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','2022-07-06 07:16:05',4,'2022-07-06 10:13:16',4,0,NULL,NULL,NULL,'dffce2c4-7adc-497e-8216-fa138d0201b1'),(1811,'Children ARV Regimen_2ndLine 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 Data Set\n \n 2022-07-06 07:16:44 UTC\n \n 2022-07-06 10:11: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 1811\n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 5A0to3.9\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_Age\n Children 0to14\n \n \n \n \n \n 5A10to13.9\n \n \n \n \n \n \n \n \n \n 5A14to19.9\n \n \n \n \n \n \n \n \n \n 5A20to24.9\n \n \n \n \n \n \n \n \n \n 5A25to34.9\n \n \n \n \n \n \n \n \n \n 5A35plus\n \n \n \n \n \n \n \n \n \n 5A4to5.9\n \n \n \n \n \n \n \n \n \n 5A6to9.9\n \n \n \n \n \n \n \n \n \n 5B0to3.9\n \n \n \n \n \n \n \n \n \n 5B10to13.9\n \n \n \n \n \n \n \n \n \n 5B14to19.9\n \n \n \n \n \n \n \n \n \n 5B20to24.9\n \n \n \n \n \n \n \n \n \n 5B25to34.9\n \n \n \n \n \n \n \n \n \n 5B35plus\n \n \n \n \n \n \n \n \n \n 5B4to5.9\n \n \n \n \n \n \n \n \n \n 5B6to9.9\n \n \n \n \n \n \n \n \n \n 5C0to3.9\n \n \n \n \n \n \n \n \n \n 5C10to13.9\n \n \n \n \n \n \n \n \n \n 5C14to19.9\n \n \n \n \n \n \n \n \n \n 5C20to24.9\n \n \n \n \n \n \n \n \n \n 5C25to34.9\n \n \n \n \n \n \n \n \n \n 5C35plus\n \n \n \n \n \n \n \n \n \n 5C4to5.9\n \n \n \n \n \n \n \n \n \n 5C6to9.9\n \n \n \n \n \n \n \n \n \n 5D0to3.9\n \n \n \n \n \n \n \n \n \n 5D10to13.9\n \n \n \n \n \n \n \n \n \n 5D14to19.9\n \n \n \n \n \n \n \n \n \n 5D20to24.9\n \n \n \n \n \n \n \n \n \n 5D25to34.9\n \n \n \n \n \n \n \n \n \n 5D35plus\n \n \n \n \n \n \n \n \n \n 5D4to5.9\n \n \n \n \n \n \n \n \n \n 5D6to9.9\n \n \n \n \n \n \n \n \n \n 5E0to3.9\n \n \n \n \n \n \n \n \n \n 5E10to13.9\n \n \n \n \n \n \n \n \n \n 5E14to19.9\n \n \n \n \n \n \n \n \n \n 5E20to24.9\n \n \n \n \n \n \n \n \n \n 5E25to34.9\n \n \n \n \n \n \n \n \n \n 5E35plus\n \n \n \n \n \n \n \n \n \n 5E4to5.9\n \n \n \n \n \n \n \n \n \n 5E6to9.9\n \n \n \n \n \n \n \n \n \n 5F0to3.9\n \n \n \n \n \n \n \n \n \n 5F10to13.9\n \n \n \n \n \n \n \n \n \n 5F14to19.9\n \n \n \n \n \n \n 5F20to24.9\n \n \n \n \n \n \n \n \n \n 5F25to34.9\n \n \n \n \n \n \n \n \n \n 5F35plus\n \n \n \n \n \n \n \n \n \n 5F4to5.9\n \n \n \n \n \n \n \n \n \n 5F6to9.9\n \n \n \n \n \n \n \n \n \n 5G0to3.9\n \n \n \n \n \n \n \n \n \n 5G10to13.9\n \n \n \n \n \n \n \n \n \n 5G14to19.9\n \n \n \n \n \n \n \n \n \n 5G20to24.9\n \n \n \n \n \n \n \n \n \n 5G25to34.9\n \n \n \n \n \n \n \n \n \n 5G35plus\n \n \n \n \n \n \n \n \n \n 5G4to5.9\n \n \n \n \n \n \n \n \n \n 5G6to9.9\n \n \n \n \n \n \n \n \n \n 5H0to3.9\n \n \n \n \n \n \n \n \n \n 5H10to13.9\n \n \n \n \n \n \n \n \n \n 5H14to19.9\n \n \n \n \n \n \n \n \n \n 5H20to24.9\n \n \n \n \n \n \n \n \n \n 5H25to34.9\n \n \n \n \n \n \n \n \n \n 5H35plus\n \n \n \n \n \n \n \n \n \n 5H4to5.9\n \n \n \n \n \n \n \n \n \n 5H6to9.9\n \n \n \n \n \n \n \n \n \n','2022-07-06 07:16:44',4,'2022-07-06 10:11:25',4,0,NULL,NULL,NULL,'437a2414-1894-4eb5-8c13-356a8e2aa747'),(1812,'Children ARV Regimen_3rdLine_2022','Children ARV Regimen_3rdLine','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_2022\n Children ARV Regimen_3rdLine\n \n 2022-07-06 10:16:11 UTC\n \n 2022-07-06 10:16: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 1812\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','2022-07-06 10:16:11',4,'2022-07-06 10:16:23',4,0,NULL,NULL,NULL,'b6b0cf68-1305-49a2-8f43-30f3f175958d'),(1813,'Children ARV Regimen_3rdLine_2022 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_2022 Data Set\n \n 2022-07-06 10:16:23 UTC\n \n 2022-07-06 14:44: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 1813\n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 6A0to3.9\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_Age\n Children 0to14\n \n \n \n \n \n 6A10to13.9\n \n \n \n \n \n \n \n \n \n 6A14to19.9\n \n \n \n \n \n \n \n \n \n 6A20to24.9\n \n \n \n \n \n \n \n \n \n 6A25to34.9\n \n \n \n \n \n \n \n \n \n 6A35plus\n \n \n \n \n \n \n \n \n \n 6A4to5.9\n \n \n \n \n \n \n \n \n \n 6A6to9.9\n \n \n \n \n \n \n \n \n \n 6B0to3.9\n \n \n \n \n \n \n \n \n \n 6B10to13.9\n \n \n \n \n \n \n \n \n \n 6B14to19.9\n \n \n \n \n \n \n \n \n \n 6B20to24.9\n \n \n \n \n \n \n \n \n \n 6B25to34.9\n \n \n \n \n \n \n \n \n \n 6B35plus\n \n \n \n \n \n \n \n \n \n 6B4to5.9\n \n \n \n \n \n \n \n \n \n 6B6to9.9\n \n \n \n \n \n \n \n \n \n 6C0to3.9\n \n \n \n \n \n \n \n \n \n 6C10to13.9\n \n \n \n \n \n \n \n \n \n 6C14to19.9\n \n \n \n \n \n \n \n \n \n 6C20to24.9\n \n \n \n \n \n \n \n \n \n 6C25to34.9\n \n \n \n \n \n \n \n \n \n 6C35plus\n \n \n \n \n \n \n \n \n \n 6C4to5.9\n \n \n \n \n \n \n \n \n \n 6C6to9.9\n \n \n \n \n \n \n \n \n \n 6D0to3.9\n \n \n \n \n \n \n \n \n \n 6D10to13.9\n \n \n \n \n \n \n \n \n \n 6D14to19.9\n \n \n \n \n \n \n \n \n \n 6D20to24.9\n \n \n \n \n \n \n \n \n \n 6D25to34.9\n \n \n \n \n \n \n \n \n \n 6D35plus\n \n \n \n \n \n \n \n \n \n 6D4to5.9\n \n \n \n \n \n \n \n \n \n 6D6to9.9\n \n \n \n \n \n \n \n \n \n 6E0to3.9\n \n \n \n \n \n \n \n \n \n 6E10to13.9\n \n \n \n \n \n \n \n \n \n 6E14to19.9\n \n \n \n \n \n \n \n \n \n 6E20to24.9\n \n \n \n \n \n \n \n \n \n 6E25to34.9\n \n \n \n \n \n \n \n \n \n 6E35plus\n \n \n \n \n \n \n \n \n \n 6E4to5.9\n \n \n \n \n \n \n \n \n \n 6E6to9.9\n \n \n \n \n \n \n \n \n \n 6F0to3.9\n \n \n \n \n \n \n \n \n \n 6F10to13.9\n \n \n \n \n \n \n \n \n \n 6F14to19.9\n \n \n \n \n \n \n \n \n \n 6F20to24.9\n \n \n \n \n \n \n \n \n \n 6F25to34.9\n \n \n \n \n \n \n \n \n \n 6F35plus\n \n \n \n \n \n \n \n \n \n 6F4to5.9\n \n \n \n \n \n \n \n \n \n 6F6to9.9\n \n \n \n \n \n \n \n \n \n','2022-07-06 10:16:23',4,'2022-07-06 14:44:30',4,0,NULL,NULL,NULL,'3fa2b422-d556-4710-bfd7-bc8a5b0c9c0b'),(1814,'TX_ML-06 Clients who are current on ART at reporting period and experienced IIT_3-5 months','TX_ML-06 Clients who are current on ART at reporting period and experienced IIT_3-5 months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_ML-06 Clients who are current on ART at reporting period and experienced IIT_3-5 months\n TX_ML-06 Clients who are current on ART at reporting period and experienced IIT_3-5 months\n \n 2022-08-10 11:03:51 UTC\n \n 2024-02-15 09:03: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 1814\n select obs_ml_clients.person_id \nfrom obs os \ninner join location l on os.location_id = l.location_id \ninner join \n( \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) < 29) as On_ART_Beginning_Quarter \n ) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n UNION \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 2249 and cast(o.value_datetime as date) >= cast(:startDate as DATE) and cast(o.value_datetime as date) <= cast(:endDate as DATE) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n) as obs_ml_clients on os.person_id = obs_ml_clients.person_id \nINNER JOIN person ON person.person_id = obs_ml_clients.person_id AND person.voided = 0 \nINNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \nWHERE os.location_id =:location or parent_location =:location \n -- INITIATED ON ART BETWEEN 3 AND 5 MONTHS AGO \n AND obs_ml_clients.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 2249 \n AND datediff(CAST(:endDate AS DATE), os.value_datetime) BETWEEN 89 AND 180 \n ) \n -- NOT Transfered Out to Another Site \n AND obs_ml_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 4155 and os.value_coded = 2146 \n AND os.obs_datetime <= CAST(:endDate AS DATE) \n ) \n -- NOT DEAD \n AND obs_ml_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 ) \nAND obs_ml_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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n )\n','2022-08-10 16:33:51',4,'2024-02-15 14:33:32',4,0,NULL,NULL,NULL,'e2a2e29e-040a-45b1-902d-fa25074d52a1'),(1815,'CI63:TxML IIT3-5','TxML IIT3-5','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI63:TxML IIT3-5\n TxML IIT3-5\n \n 2022-08-10 11:07:17 UTC\n \n 2022-08-10 11:08: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 1815\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-08-10 11:07:17',4,'2022-08-10 11:08:59',4,0,NULL,NULL,NULL,'781f34cd-9cce-41ef-acbe-b89b0e1257e4'),(1816,'TX_RTT-02 Clients with IIT for < 3 months in previous period who restarted ARV\'s during current period','TX_RTT-02 Clients with IIT for < 3 months in previous period who restarted ARV\'s during current period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_RTT-02 Clients with IIT for < 3 months in previous period who restarted ARV's during current period\n TX_RTT-02 Clients with IIT for < 3 months in previous period who restarted ARV's during current period\n \n 2022-08-23 16:34:31 UTC\n \n 2024-02-15 08:22: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 1816\n select distinct o.person_id \nfrom obs o \n-- PATIENTS WITH NO CLINICAL CONTACT OR ARV PICK-UP FOR GREATER THAN 28 DAYS \n-- SINCE THEIR LAST EXPECTED CONTACT WHO RESTARTED ARVs WITHIN THE REPORTING PERIOD \ninner join location l on o.location_id = l.location_id \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND patient.voided = 0 AND o.voided = 0 \nAND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) BETWEEN 29 and 90) as Missed_Greater_Than_28Days \n ) \n \n -- Client Seen: As either patient OR Treatment Buddy \n AND ( \n o.person_id 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 os.obs_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n \n -- Client Seen and Date Restarted picked \n OR o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 3708 AND os.value_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n ) \n -- Still on treatment at the end of the reporting period \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime >= cast(:startDate as DATE) and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) <= 28) as Still_On_Treatment_End_Period \n ) \n \n -- Transfered Out to Another Site during their latest encounter before the start date \n AND o.person_id not in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS last_obs_tout \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 4155 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having last_obs_tout = 2146) as Transfered_Out_In_Last_Encounter \n ) \n \n-- NOT Transfered In from another Site \n AND o.person_id not in ( \n select os.person_id \n from obs os \n where (os.concept_id = 2253 AND DATE(os.value_datetime) BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE)) \n AND os.voided = 0 \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 \n ) \n AND o.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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \nWHERE (o.location_id =:location or parent_location =:location)\n','2022-08-23 22:04:31',4,'2024-02-15 13:52:47',4,0,NULL,NULL,NULL,'505841df-fa38-436c-8463-8a437f536b69'),(1817,'TX_RTT-03 Clients with IIT for 3-5 months in previous period who restarted ARV\'s during current period','TX_RTT-03 Clients with IIT for 3-5 months in previous period who restarted ARV\'s during current period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_RTT-03 Clients with IIT for 3-5 months in previous period who restarted ARV's during current period\n TX_RTT-03 Clients with IIT for 3-5 months in previous period who restarted ARV's during current period\n \n 2022-08-23 16:42:57 UTC\n \n 2024-02-15 08:26: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 1817\n select distinct o.person_id \nfrom obs o \n-- PATIENTS WITH NO CLINICAL CONTACT OR ARV PICK-UP FOR GREATER THAN 28 DAYS \n-- SINCE THEIR LAST EXPECTED CONTACT WHO RESTARTED ARVs WITHIN THE REPORTING PERIOD \ninner join location l on o.location_id = l.location_id \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND patient.voided = 0 AND o.voided = 0 \nAND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) BETWEEN 89 and 180) as Missed_Between_89_and_180Days \n ) \n \n -- Client Seen: As either patient OR Treatment Buddy \n AND ( \n o.person_id 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 os.obs_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n \n -- Client Seen and Date Restarted picked \n OR o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 3708 AND os.value_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n ) \n -- Still on treatment at the end of the reporting period \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime >= cast(:startDate as DATE) and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) <= 28) as Still_On_Treatment_End_Period \n ) \n \n -- Transfered Out to Another Site during their latest encounter before the start date \n AND o.person_id not in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS last_obs_tout \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 4155 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having last_obs_tout = 2146) as Transfered_Out_In_Last_Encounter \n ) \n \n-- NOT Transfered In from another Site \n AND o.person_id not in ( \n select os.person_id \n from obs os \n where (os.concept_id = 2253 AND DATE(os.value_datetime) BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE)) \n AND os.voided = 0 \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 \n ) \n AND o.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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \nWHERE (o.location_id =:location or parent_location =:location)\n','2022-08-23 22:12:57',4,'2024-02-15 13:56:51',4,0,NULL,NULL,NULL,'129f5049-8d6d-4cd9-8922-7cf72b623ab3'),(1818,' TX_RTT-04 Clients with IIT for >6 months in previous period who restarted ARV\'s during current period',' TX_RTT-04 Clients with IIT for >6 months in previous period who restarted ARV\'s during current period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_RTT-04 Clients with IIT for >6 months in previous period who restarted ARV's during current period\n TX_RTT-04 Clients with IIT for >6 months in previous period who restarted ARV's during current period\n \n 2022-08-23 16:45:46 UTC\n \n 2024-02-15 08:42: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 endDateAS\n \n java.util.Date\n true\n \n \n 1818\n select distinct o.person_id \nfrom obs o \n-- PATIENTS WITH NO CLINICAL CONTACT OR ARV PICK-UP FOR GREATER THAN 28 DAYS \n-- SINCE THEIR LAST EXPECTED CONTACT WHO RESTARTED ARVs WITHIN THE REPORTING PERIOD \ninner join location l on o.location_id = l.location_id \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND patient.voided = 0 AND o.voided = 0 \nAND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) >= 180) as Missed_Greater_than_180Days \n ) \n \n -- Client Seen: As either patient OR Treatment Buddy \n AND ( \n o.person_id 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 os.obs_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n \n -- Client Seen and Date Restarted picked \n OR o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 3708 AND os.value_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n ) \n -- Still on treatment at the end of the reporting period \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime >= cast(:startDate as DATE) and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) <= 28) as Still_On_Treatment_End_Period \n ) \n \n -- Transfered Out to Another Site during their latest encounter before the start date \n AND o.person_id not in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS last_obs_tout \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 4155 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having last_obs_tout = 2146) as Transfered_Out_In_Last_Encounter \n ) \n \n-- NOT Transfered In from another Site \n AND o.person_id not in ( \n select os.person_id \n from obs os \n where (os.concept_id = 2253 AND DATE(os.value_datetime) BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE)) \n AND os.voided = 0 \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 \n ) \n AND o.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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \nWHERE (o.location_id =:location or parent_location =:location)\n','2022-08-23 22:15:46',4,'2024-02-15 14:12:31',4,0,NULL,NULL,NULL,'afc2a5d5-53e4-427a-9491-b3b1609bbe69'),(1819,'CI64:TxRTT IIT<3months','CI64:TxRTT IIT<3months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI64:TxRTT IIT<3months\n CI64:TxRTT IIT<3months\n \n 2022-08-24 07:46:14 UTC\n \n 2022-08-24 07:47: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 1819\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-08-24 07:46:14',4,'2022-08-24 07:47:14',4,0,NULL,NULL,NULL,'6c4e2daf-e83f-4899-98f5-203f33ee4827'),(1820,'CI65:TxRTT IIT_3-5months','CI65:TxRTT IIT_3-5months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI65:TxRTT IIT_3-5months\n CI65:TxRTT IIT_3-5months\n \n 2022-08-24 07:47:56 UTC\n \n 2022-08-24 07:48: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 1820\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-08-24 07:47:56',4,'2022-08-24 07:48:48',4,0,NULL,NULL,NULL,'714af509-9ade-48b5-b6f0-10d7499a6f15'),(1821,'CI66:TxRTT IIT_6+months','CI66:TxRTT IIT_6+months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI66:TxRTT IIT_6+months\n CI66:TxRTT IIT_6+months\n \n 2022-08-24 07:49:18 UTC\n \n 2022-08-24 07:49: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 1821\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-08-24 07:49:18',4,'2022-08-24 07:49:56',4,0,NULL,NULL,NULL,'271261f4-75c6-4c64-a6f0-7be2d40c33c3'),(1822,'Pulmonary Bacteriologically Confirmed New','New Pulmonary Bacteriologically Confirmed clients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Bacteriologically Confirmed New\n New Pulmonary Bacteriologically Confirmed clients\n \n 2023-03-27 10:50:04 UTC\n \n 2023-03-29 16:41: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 1822\n select distinct o.person_id \n \n from obs o \ninner join location l on o.location_id = l.location_id \n \n -- Relapsed TB Client \nWHERE (o.location_id =:location or parent_location =:location) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n -- TB Start Date \n where ob.concept_id = 2237 \n and ob.value_datetime >= :startDate \n and ob.value_datetime <= :endDate \n and ob.voided = 0 \n ) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- New Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1034 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n ) \n \n \n AND o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Patient must not be a tranfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND (os.obs_datetime BETWEEN :startDate AND :endDate) \n AND os.voided = 0 \n )\n','2023-03-27 12:50:04',4,'2023-03-29 18:41:33',4,0,NULL,NULL,NULL,'5ab3fc4d-0d1e-4a30-b0c7-d35c68f7f19a'),(1823,'NewRelapse_Tb_Treatment_History','Tb Treatment History - New and Relapse Patients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n NewRelapse_Tb_Treatment_History\n Tb Treatment History - New and Relapse Patients\n \n 2023-03-27 11:51:48 UTC\n \n 2023-03-27 20:29: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 1823\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age , Gender, age_group, 'New Patient' AS 'TB_Treatment_History' \n FROM \n \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 -- New TB Patient \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n -- TB Start Date \n where ob.concept_id = 2237 \n and ob.value_datetime >= CAST(:startDate AS DATE) \n and ob.value_datetime <= CAST(:endDate AS DATE) \n and ob.voided = 0 \n ) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- New Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1034 \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \n \n AND o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Patient must not be a tranfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND (os.obs_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE)) \n AND patient.voided = 0 AND os.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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n \n UNION \n \n (SELECT distinct Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age , Gender, age_group, 'Relapsed Patient' AS 'TB_Treatment_History' \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 -- Relapsed TB Client \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n -- TB Start Date \n where ob.concept_id = 2237 \n and ob.value_datetime >= CAST(:startDate AS DATE) \n and ob.value_datetime <= CAST(:endDate AS DATE) \n ) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- Relapsed Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1084 \n and ob.value_datetime >= CAST(:startDate AS DATE) \n and ob.value_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \n \n \n AND o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Client must not be a transfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND os.obs_datetime >= CAST(:startDate AS DATE) \n and os.obs_datetime <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND os.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 \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 RELAPSE_TB_CLIENTS \n ORDER BY RELAPSE_TB_CLIENTS.Age) \n) AS NewRelapsed)\n','2023-03-27 17:21:48',4,'2023-03-28 01:59:53',4,0,NULL,NULL,NULL,'7f8a23bd-eec0-40a6-8181-cda3d0aab0bd'),(1824,'Pulmonary Bacteriologically Confirmed Relapse','Pulmonary Bacteriologically Confirmed Relapse','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Bacteriologically Confirmed Relapse\n Pulmonary Bacteriologically Confirmed Relapse\n \n 2023-03-27 12:10:01 UTC\n \n 2023-03-29 16:45: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 1824\n select o.person_id \n from obs o \ninner join location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \nWHERE (o.location_id =:location or parent_location =:location) \nAND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n -- TB Start Date \n where ob.concept_id = 2237 \n and ob.value_datetime >= :startDate \n and ob.value_datetime <= :endDate \n ) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- Relapsed Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1084 \n and ob.value_datetime >= :startDate \n and ob.value_datetime <= :endDate \n ) \n ) \n \n \n \n AND o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Client must not be a transfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND os.obs_datetime >= :startDate \n and os.obs_datetime <= :endDate \n AND patient.voided = 0 AND os.voided = 0 \n )\n','2023-03-27 14:10:01',4,'2023-03-29 18:45:37',4,0,NULL,NULL,NULL,'e495a330-c538-4fa2-9279-e0c03ec69b51'),(1825,'Pulmonary Bacteriologically Confirmed Excluding Relapse','Pulmonary Bacteriologically Confirmed Excluding Relapse','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Bacteriologically Confirmed Excluding Relapse\n Pulmonary Bacteriologically Confirmed Excluding Relapse\n \n 2023-03-27 17:01:52 UTC\n \n 2023-03-29 16:38: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 1825\n select distinct o.person_id \n from obs o \ninner join location l on o.location_id = l.location_id \n \n -- Relapsed TB Client \nWHERE (o.location_id =:location or parent_location =:location) \n AND o.concept_id = 3785 and o.value_coded in (3786,1037) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n -- TB Start Date \n where ob.concept_id = 2237 \n and ob.value_datetime >= :startDate \n and ob.value_datetime <= :endDate \n ) \n \n AND o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Client must not be a transfer in \n where os.concept_id = 3772 and os.value_coded = 3786 \n AND os.obs_datetime >= :startDate \n and os.obs_datetime <= :endDate \n AND os.voided = 0) \n\n','2023-03-27 19:01:52',4,'2023-03-29 18:38:41',4,0,NULL,NULL,NULL,'23ba6606-91b7-4f7c-9142-73d6a43769a3'),(1826,'New and Relapse with document HIV Status','New and Relapse patients with document HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse with document HIV Status\n New and Relapse patients with document HIV Status\n \n 2023-03-27 19:38:11 UTC\n \n 2023-03-27 21:21: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 1826\n SELECT DISTINCT o.person_id \n from obs o \n -- New and Relapse with Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3785 and ob.value_coded in (1034, 1084) -- New and Relapse \n and ob.voided = 0 \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE)\n','2023-03-28 01:08:11',4,'2023-03-28 02:51:39',4,0,NULL,NULL,NULL,'ee4e2170-5dd7-423e-bc84-f0c13c3a9b4f'),(1827,'Retreatment with documented HIV status','Retreatment Excl. Relapse client with documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment with documented HIV status\n Retreatment Excl. Relapse client with documented HIV Status\n \n 2023-03-27 19:50:19 UTC\n \n 2023-03-27 19:53: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 1827\n SELECT DISTINCT o.person_id \n from obs o \n -- New and Relapse with Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3785 and ob.value_coded in (3786, 1037) -- Retreatmentafter LTFU/Failure \n and ob.voided = 0 \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 01:20:19',4,'2023-03-28 01:23:28',4,0,NULL,NULL,NULL,'17edcc8f-3d38-49dd-a6f4-a5384cdb7245'),(1828,'Children < 15 with Documented HIV Status','Children (0 - 14) with documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children < 15 with Documented HIV Status\n Children (0 - 14) with documented HIV Status\n \n 2023-03-27 20:10:47 UTC\n \n 2023-03-27 20:11:20 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 1828\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 \n from obs o \n -- Documented HIV, Status \n inner join location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \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 having Age < 15\n','2023-03-28 01:40:47',4,'2023-03-28 01:41:20',4,0,NULL,NULL,NULL,'ca5b1d37-8229-474d-8125-2486520685fd'),(1829,'Pulmonary Clinically Diagnosed New','Pulmonary Clinically Diagnosed New','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Clinically Diagnosed New\n Pulmonary Clinically Diagnosed New\n \n 2023-03-27 20:39:34 UTC\n \n 2023-03-28 08:18: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 1829\n select distinct o.person_id \n FROM obs o \ninner join location l on o.location_id = l.location_id \n -- Clinical Diagnosis X-Ray \n and o.concept_id = 4673 and o.value_coded = 4171 \nAND o.person_id in ( \nselect o.person_id from obs o \nwhere o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n -- TB Start Date \n where ob.concept_id = 2237 \n and ob.value_datetime >= :startDate \n and ob.value_datetime <= :endDate \n and ob.voided = 0 \n ) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- New Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1034 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n ) \n \n \n AND o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Patient must not be a tranfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND (os.obs_datetime BETWEEN :startDate AND :endDate) \n and os.voided = 0 \n ) \n \n) \n and o.obs_datetime >= :startDate \n and o.obs_datetime <= :endDate \n and o.voided = 0 \n and o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB \n where ob.concept_id = 3788 and ob.value_coded = 1018 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n or o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB, Clinically Diagnosed \n where ob.concept_id = 2236 and ob.value_coded = 2235 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n )\n','2023-03-28 02:09:34',4,'2023-03-28 13:48:26',4,0,NULL,NULL,NULL,'34bcf70d-0178-4dcc-ab38-9046e4bcedd1'),(1830,'Miners with Documented HIV Status','High risk population of miners with documented HIV','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Miners with Documented HIV Status\n High risk population of miners with documented HIV\n \n 2023-03-27 20:45:17 UTC\n \n 2023-03-27 20: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 1830\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3667 -- Population (Miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 02:15:17',4,'2023-03-28 02:16:08',4,0,NULL,NULL,NULL,'001d7c51-fa6b-45d5-9690-cc6dce14a608'),(1831,'Ex-Miners with Documented HIV Status','High risk population of Ex Miners with Documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex-Miners with Documented HIV Status\n High risk population of Ex Miners with Documented HIV Status\n \n 2023-03-27 20:47:57 UTC\n \n 2023-03-28 09:17: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 1831\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3668 -- Population (Ex-Miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 02:17:57',4,'2023-03-28 14:47:41',4,0,NULL,NULL,NULL,'10248e4b-2f29-447e-814a-6d5b10398656'),(1832,'Factory Workers with Documented HIV Status','High risk population of Factory Workers with Documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Workers with Documented HIV Status\n High risk population of Factory Workers with Documented HIV Status\n \n 2023-03-27 20:54:48 UTC\n \n 2023-03-27 20:55: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 1832\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3669 -- Population (Factory Workers) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 02:24:48',4,'2023-03-28 02:25:05',4,0,NULL,NULL,NULL,'bb934645-58c2-4c19-bbd7-0ebf35fa3f7a'),(1833,'Public transport operators with Documented HIV Status','High risk population of Public transport operators with Documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public transport operators with Documented HIV Status\n High risk population of Public transport operators with Documented HIV Status\n \n 2023-03-27 20:58:19 UTC\n \n 2023-03-28 20:14: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 1833\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 4654 -- Population (Public transport operators) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 02:28:19',4,'2023-03-29 01:44:32',4,0,NULL,NULL,NULL,'0c91b258-01ae-4928-be76-91201cadad93'),(1834,'Health workers with Documented HIV Status','High risk population of Health workers with Documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health workers with Documented HIV Status\n High risk population of Health workers with Documented HIV Status\n \n 2023-03-27 21:04:15 UTC\n \n 2023-03-27 21:04: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 1834\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 4670 -- Population (Health workers) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 02:34:15',4,'2023-03-28 02:34:38',4,0,NULL,NULL,NULL,'7736630e-9da2-4ec0-b131-fe9e2ef01e00'),(1835,'Correctional Staff and inmates with Documented HIV Status','High risk population of Correctional Staff and inmates with Documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Correctional Staff and inmates with Documented HIV Status\n High risk population of Correctional Staff and inmates with Documented HIV Status\n \n 2023-03-27 21:06:32 UTC\n \n 2023-03-27 21:10: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 1835\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded in (3779, 3671) -- Population (Correctional Staff and inmates) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 02:36:32',4,'2023-03-28 02:40:03',4,0,NULL,NULL,NULL,'58ac8a09-0a12-4ab0-acb4-1fe8d1d81b77'),(1836,'RetreatmentExRelapse_Tb_Treatment_History','Retreatment Exclusive Relapse Tb Treatment History','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n RetreatmentExRelapse_Tb_Treatment_History\n Retreatment Exclusive Relapse Tb Treatment History\n \n 2023-03-27 21:07:51 UTC\n \n 2023-03-27 21:12: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 1836\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 Id \nFROM \n((SELECT distinct Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- TB Retreatment Exclusive Relapse \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- TB Retreatment Exclusive Relapse \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded in (3786,1037) \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) AS RetreatmentExRelapse)\n','2023-03-28 02:37:51',4,'2023-03-28 02:42:07',4,0,NULL,NULL,NULL,'7263505b-34d2-4167-9d3f-4cdae66218f8'),(1837,'NewRelapse_Tb_Treatment_History','NewRelapse_Tb_Treatment_History','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n NewRelapse_Tb_Treatment_History\n NewRelapse_Tb_Treatment_History\n \n 2023-03-27 21:17:20 UTC\n \n 2023-03-27 21: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 1837\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-28 02:47:20',4,'2023-03-28 02:50:31',4,0,NULL,NULL,NULL,'20879b46-ecbd-4ff9-818a-3c761bcf5ebd'),(1838,'New and Relapse with Positive HIV Status','New and Relapse with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse with Positive HIV Status\n New and Relapse with Positive HIV Status\n \n 2023-03-27 21:20:17 UTC\n \n 2023-03-29 20:36: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 1838\n SELECT DISTINCT o.person_id \n from obs o \n -- New and Relapse with Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3785 and ob.value_coded in (1034, 1084) -- New/Relapse with HIV Status \n and ob.voided = 0 \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-27 23:20:17',4,'2023-03-29 22:36:19',4,0,NULL,NULL,NULL,'02c505a1-b724-422b-8c31-69440e233a0d'),(1839,'RetreatmentExRelapse_Tb_Treatment_History','Retreatment Exclusive Relapse - Tb Treatment History','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n RetreatmentExRelapse_Tb_Treatment_History\n Retreatment Exclusive Relapse - Tb Treatment History\n \n 2023-03-27 21:25:15 UTC\n \n 2023-03-27 21:26: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 1839\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-28 02:55:15',4,'2023-03-28 02:56:10',4,0,NULL,NULL,NULL,'f901b38b-95e7-4bcc-ace1-ce86030ba88e'),(1840,'TB Notification - Block 2','TB Notification - Block 2','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Notification - Block 2\n TB Notification - Block 2\n \n 2023-03-27 21:45:01 UTC\n \n 2023-03-27 21:45: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 1840\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-03-28 03:15:01',4,'2023-03-28 03:15:21',4,0,NULL,NULL,NULL,'8ab1160e-aca4-4d59-bd02-0269e8a3889a'),(1841,'TB Notification - 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 Notification - Block 2 Data Set\n \n 2023-03-27 21:45:21 UTC\n \n 2024-02-29 14:25: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 1841\n \n \n DM_Sex\n \n \n \n \n \n \n DM_TB_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n NwRlpsF1-4\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_TB_Age\n 01-04yrs\n \n \n \n \n \n NwRlpsF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 05-09yrs\n \n \n \n \n \n NwRlpsM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 01-04yrs\n \n \n \n \n \n NwRlpsM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 05-09yrs\n \n \n \n \n \n NwRlpseF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n Under1yr\n \n \n \n \n \n NwRlpseM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n Under1yr\n \n \n \n \n \n NwRsF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 10-14yrs\n \n \n \n \n \n NwRsF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 15-19yrs\n \n \n \n \n \n NwRsF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 20-24yrs\n \n \n \n \n \n NwRsF25-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 25-34yrs\n \n \n \n \n \n NwRsF35-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 35-44yrs\n \n \n \n \n \n NwRsF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 45-49yrs\n \n \n \n \n \n NwRsF50-64\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 50-64yrs\n \n \n \n \n \n NwRsF65+\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 65Plus\n \n \n \n \n \n NwRsM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 10-14yrs\n \n \n \n \n \n NwRsM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 15-19yrs\n \n \n \n \n \n NwRsM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 20-24yrs\n \n \n \n \n \n NwRsM25-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 25-34yrs\n \n \n \n \n \n NwRsM35-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 35-44yrs\n \n \n \n \n \n NwRsM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 45-49yrs\n \n \n \n \n \n NwRsM50-64\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 50-64yrs\n \n \n \n \n \n NwRsM65+\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 65Plus\n \n \n \n \n \n RetreatF<1\n \n \n \n \n \n \n \n \n \n RetreatM<1\n \n \n \n \n \n \n RetrtF1-4\n \n \n \n \n \n \n RetrtF5-9\n \n \n \n \n \n \n RetrtM1-4\n \n \n \n \n \n \n RetrtM5-9\n \n \n \n \n \n \n RtrtF10-14\n \n \n \n \n \n \n RtrtF15-19\n \n \n \n \n \n \n RtrtF20-24\n \n \n \n \n \n \n RtrtF25-34\n \n \n \n \n \n \n RtrtF35-44\n \n \n \n \n \n \n RtrtF45-49\n \n \n \n \n \n \n RtrtF50-64\n \n \n \n \n \n \n RtrtF65+\n \n \n \n \n \n \n RtrtM10-14\n \n \n \n \n \n \n RtrtM15-19\n \n \n \n \n \n \n RtrtM20-24\n \n \n \n \n \n \n RtrtM25-34\n \n \n \n \n \n \n RtrtM35-44\n \n \n \n \n \n \n RtrtM45-49\n \n \n \n \n \n \n RtrtM50-64\n \n \n \n \n \n \n RtrtM65+\n \n \n \n \n \n \n','2023-03-28 03:15:21',4,'2024-02-29 19:55:50',4,0,NULL,NULL,NULL,'68f0aaca-a6a0-4cb5-aebb-e57d5ce5b2cd'),(1844,'Retreatment with Positive HIV status','Retreatment Excl. Relapse with Positive HIV status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment with Positive HIV status\n Retreatment Excl. Relapse with Positive HIV status\n \n 2023-03-28 08:28:56 UTC\n \n 2023-03-28 08:30: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 1844\n SELECT DISTINCT o.person_id \n from obs o \n -- New and Relapse with Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3785 and ob.value_coded in (3786, 1037) -- Retreatmentafter LTFU/Failure with HIV Status \n and ob.voided = 0 \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 13:58:56',4,'2023-03-28 14:00:38',4,0,NULL,NULL,NULL,'d48e3545-1e4d-4d7a-a812-5fb7111cbf72'),(1845,'Pulmonary Clinically Diagnosed Relapse','Pulmonary Clinically Diagnosed Relapse','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Clinically Diagnosed Relapse\n Pulmonary Clinically Diagnosed Relapse\n \n 2023-03-28 08:30:26 UTC\n \n 2023-03-28 09: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 1845\n select distinct o.person_id \n FROM obs o \n \n where o.concept_id = 4673 and o.value_coded = 4171 \n and o.obs_datetime >= :startDate \n and o.obs_datetime <= :endDate \n and o.person_id in ( \n select distinct o.person_id \n from obs o \n -- Relapsed TB Client \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n -- TB Start Date \n where ob.concept_id = 2237 \n and ob.value_datetime >= :startDate \n and ob.value_datetime <= :endDate \n ) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- Relapsed Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1084 \n and ob.value_datetime >= :startDate \n and ob.value_datetime <= :endDate \n ) \n ) \n \n \n \n AND o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Client must not be a transfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND os.obs_datetime >= :startDate \n and os.obs_datetime <= :endDate \n and os.voided = 0 \n ) \n ) \n \n and o.voided = 0 \n and o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB \n where ob.concept_id = 3788 and ob.value_coded = 1018 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n or o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB, Clinically Diagnosed \n where ob.concept_id = 2236 and ob.value_coded = 2235 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n \n \n','2023-03-28 14:00:26',4,'2023-03-28 14:44:26',4,0,NULL,NULL,NULL,'5d45f128-1037-42d6-939d-3ae6929bfd6c'),(1846,'DM_TB_Age','DM_TB_Age','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n DM_TB_Age\n DM_TB_Age\n \n 2023-03-28 08:34:09 UTC\n \n 2024-02-29 14:04:18 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n 1846\n \n \n 01-04yrs\n \n \n \n \n maxAge\n 4\n \n \n minAge\n 1\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 05-09yrs\n \n \n \n \n maxAge\n 9\n \n \n minAge\n 5\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 10-14yrs\n \n \n \n \n maxAge\n 14\n \n \n minAge\n 10\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 15-19yrs\n \n \n \n \n maxAge\n 19\n \n \n minAge\n 15\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 20-24yrs\n \n \n \n \n maxAge\n 24\n \n \n minAge\n 20\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 25-34yrs\n \n \n \n \n maxAge\n 34\n \n \n minAge\n 25\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 35-44yrs\n \n \n \n \n maxAge\n 44\n \n \n minAge\n 35\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 45-49yrs\n \n \n \n \n maxAge\n 49\n \n \n minAge\n 45\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 50-64yrs\n \n \n \n \n maxAge\n 64\n \n \n minAge\n 50\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 65Plus\n \n \n \n \n maxAge\n 120\n \n \n minAge\n 65\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n Under1yr\n \n \n \n \n maxAge\n 0\n \n \n minAge\n 0\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n','2023-03-28 14:04:09',4,'2024-02-29 19:34:18',4,0,NULL,NULL,NULL,'68d03856-4b9b-4d8d-ba8f-bc698222c9f2'),(1847,'Children < 15 with Positive HIV Status','High risk population for Children < 15 with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children < 15 with Positive HIV Status\n High risk population for Children < 15 with Positive HIV Status\n \n 2023-03-28 08:43:51 UTC\n \n 2023-03-28 08:54: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 1847\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 \n from obs o \n -- HIV PositiveStatus \n inner join location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \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 having Age < 15\n','2023-03-28 14:13:51',4,'2023-03-28 14:24:04',4,0,NULL,NULL,NULL,'63b6abab-6261-4d20-9601-74454ea10cd6'),(1848,'Miners with Positive HIV Status','High risk population of miners with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Miners with Positive HIV Status\n High risk population of miners with Positive HIV Status\n \n 2023-03-28 08:58:19 UTC\n \n 2023-03-28 09:01: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 1848\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3667 -- Population (Miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 14:28:19',4,'2023-03-28 14:31:36',4,0,NULL,NULL,NULL,'d4d85343-09fc-473b-a650-50f444deee3e'),(1849,'Ex-Miners with Positive HIV Status',' High risk population of Ex Miners with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex-Miners with Positive HIV Status\n High risk population of Ex Miners with Positive HIV Status\n \n 2023-03-28 09:10:47 UTC\n \n 2023-03-28 09:17: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 1849\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3668 -- Population (Ex-Miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 14:40:47',4,'2023-03-28 14:47:26',4,0,NULL,NULL,NULL,'33fa2a02-6cb8-4850-8d80-18d86f0516a8'),(1850,'Pulmonary Clinically Diagnosed Excluding Relapse','Pulmonary Clinically Diagnosed Excluding Relapse','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Clinically Diagnosed Excluding Relapse\n Pulmonary Clinically Diagnosed Excluding Relapse\n \n 2023-03-28 09:16:40 UTC\n \n 2023-03-28 09:55: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 1850\n select distinct o.person_id \n FROM obs o \n \n where o.obs_datetime >= :startDate \n and o.obs_datetime <= :endDate \n AND o.concept_id = 3785 and o.value_coded in (3786,1037) \n and o.voided = 0 \n and o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB \n where ob.concept_id = 3788 and ob.value_coded = 1018 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n or o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB, Clinically Diagnosed \n where ob.concept_id = 2236 and ob.value_coded = 2235 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n \n \n','2023-03-28 14:46:40',4,'2023-03-28 15:25:11',4,0,NULL,NULL,NULL,'8a1f3d92-c5ec-4892-920b-5bae45020424'),(1851,'Factory Workers with Positive HIV Status','High risk population of Factory Workers with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Workers with Positive HIV Status\n High risk population of Factory Workers with Positive HIV Status\n \n 2023-03-28 09:22:07 UTC\n \n 2023-03-28 09:23: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 1851\n select distinct o.person_id \n from obs o \n -- Positive HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3669 -- Population (Factory Workers) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 14:52:07',4,'2023-03-28 14:53:45',4,0,NULL,NULL,NULL,'e7f0599c-bb8c-4d2d-94a7-4b99e0f1f7af'),(1852,'Public transport with Positive HIV Status','High risk population of Public transport operators with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public transport with Positive HIV Status\n High risk population of Public transport operators with Positive HIV Status\n \n 2023-03-28 09:26:12 UTC\n \n 2023-03-28 09:28: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 1852\n select distinct o.person_id \n from obs o \n -- Positive HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 4654 -- Population (Public transport operators) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 14:56:12',4,'2023-03-28 14:58:18',4,0,NULL,NULL,NULL,'17f9486c-aefe-4a21-b3ad-d5c685280640'),(1853,'Health workers with Positive HIV Status',' High risk population of Health workers with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health workers with Positive HIV Status\n High risk population of Health workers with Positive HIV Status\n \n 2023-03-28 09:31:54 UTC\n \n 2023-03-28 09: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 1853\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 4670 -- Population (Health workers) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 15:01:54',4,'2023-03-28 15:02:36',4,0,NULL,NULL,NULL,'e071852e-15c9-4eb6-92a9-c1c8157db41d'),(1854,'Correctional Staff and inmates with Positive HIV Status','High risk population of Correctional Staff and inmates with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Correctional Staff and inmates with Positive HIV Status\n High risk population of Correctional Staff and inmates with Positive HIV Status\n \n 2023-03-28 09:35:03 UTC\n \n 2023-03-28 09: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 1854\n select distinct o.person_id \n from obs o \n -- Positive HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded in (3779, 3671) -- Population (Correctional Staff and inmates) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 15:05:03',4,'2023-03-28 15:05:43',4,0,NULL,NULL,NULL,'d6df7665-4e94-4ae6-886e-c1fb05a4a0b1'),(1855,'Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - New','Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - New','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - New\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - New\n \n 2023-03-28 10:05:40 UTC\n \n 2023-03-29 16:14: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 1855\n select distinct ob.person_id \n FROM obs ob \ninner join location l on ob.location_id = l.location_id \n \n where ob.concept_id = 3788 and ob.value_coded = 2233 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.person_id in \n ( \n select distinct o.person_id \n \n from obs o \n -- New TB Patient \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n -- TB Start Date \n where ob.concept_id = 2237 \n and ob.value_datetime >= :startDate \n and ob.value_datetime <= :endDate \n and ob.voided = 0 \n ) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- New Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1034 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n ) \n \n \n AND o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Patient must not be a tranfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND (os.obs_datetime BETWEEN :startDate AND :endDate) \n ) \n ) \n and ob.voided = 0 \n or ob.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Extra Pulmonary TB in ART Intake \n where ob.concept_id = 2236 and ob.value_coded = 2233 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n \n','2023-03-28 12:05:40',4,'2023-03-29 18:14:16',4,0,NULL,NULL,NULL,'155d4939-e304-4aa0-a2d4-efc18644affa'),(1856,'HHCM with Documented HIV Status','High risk population of HHCM with Documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM with Documented HIV Status\n High risk population of HHCM with Documented HIV Status\n \n 2023-03-28 10:39:40 UTC\n \n 2023-03-28 10:42: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 1856\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3777 -- Population (Household member of current miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 16:09:40',4,'2023-03-28 16:12:42',4,0,NULL,NULL,NULL,'6584ebef-9d17-4b53-80ba-7396b170919f'),(1857,'HHXM with Documented HIV Status','High risk population of HHXM with Documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM with Documented HIV Status\n High risk population of HHXM with Documented HIV Status\n \n 2023-03-28 10:46:20 UTC\n \n 2023-03-28 10:48: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 1857\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3778 -- Population (Household member of Ex miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 16:16:20',4,'2023-03-28 16:18:26',4,0,NULL,NULL,NULL,'f06272eb-e3f7-4d7e-82d1-1e3a391a8b9e'),(1858,'HHCM with Positive HIV Status','High risk population of HHCM with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM with Positive HIV Status\n High risk population of HHCM with Positive HIV Status\n \n 2023-03-28 10:54:07 UTC\n \n 2023-03-28 10:59: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 1858\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3777 -- Population (Household member of current miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 16:24:07',4,'2023-03-28 16:29:14',4,0,NULL,NULL,NULL,'2b06bd4f-a633-48d8-9a9a-12ae5f84001b'),(1859,'HHXM with Positive HIV Status','High risk population of HHXM with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM with Positive HIV Status\n High risk population of HHXM with Positive HIV Status\n \n 2023-03-28 11:03:32 UTC\n \n 2023-03-28 11:08: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 1859\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3778 -- Population (Household member of Ex miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 16:33:32',4,'2023-03-28 16:38:06',4,0,NULL,NULL,NULL,'46bd9d48-49d2-4fd5-b433-f1123f217588'),(1860,'Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Relapse','Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Relapse','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Relapse\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Relapse\n \n 2023-03-28 11:42:29 UTC\n \n 2023-03-29 16:33: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 1860\n select distinct ob.person_id \n FROM obs ob \ninner join location l on ob.location_id = l.location_id \n \n where ob.concept_id = 3788 and ob.value_coded = 2233 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.person_id in \n ( \n select distinct o.person_id \n \n from obs o \n -- New TB Patient \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n -- TB Start Date \n where ob.concept_id = 2237 \n and ob.value_datetime >= :startDate \n and ob.value_datetime <= :endDate \n and ob.voided = 0 \n ) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- New Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1034 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n ) \n \n \n AND o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Patient must not be a tranfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND (os.obs_datetime BETWEEN :startDate AND :endDate) \n ) \n ) \n and ob.voided = 0 \n or ob.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Extra Pulmonary TB in ART Intake \n where ob.concept_id = 2236 and ob.value_coded = 2233 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n \n','2023-03-28 13:42:29',4,'2023-03-29 18:33:58',4,0,NULL,NULL,NULL,'b2905cf9-63d5-4b7b-9a72-0f76caf70da3'),(1861,'HHXM with HIV Positive on CPT/Dapzone','High risk population of HHXM with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM with HIV Positive on CPT/Dapzone\n High risk population of HHXM with HIV Positive on CPT/Dapzone\n \n 2023-03-28 13:51:41 UTC\n \n 2023-03-28 13:52: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 1861\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3778 -- Population (Household member of Ex miner) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 19:21:41',4,'2023-03-28 19:22:17',4,0,NULL,NULL,NULL,'0133ee85-0abd-494a-86b7-6818670bd37b'),(1862,'Extra-pulmonary (bacteriologically confirmed or clinically diagnosed) - Exlude relapse','Extra-pulmonary (bacteriologically confirmed or clinically diagnosed) - Exlude relapse','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Extra-pulmonary (bacteriologically confirmed or clinically diagnosed) - Exlude relapse\n Extra-pulmonary (bacteriologically confirmed or clinically diagnosed) - Exlude relapse\n \n 2023-03-28 14:29:38 UTC\n \n 2023-03-29 16:36: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 1862\n select distinct ob.person_id \n FROM obs ob \n \ninner join location l on ob.location_id = l.location_id \n \n -- Relapsed TB Client \nWHERE (ob.location_id =:location or parent_location =:location) \nand ob.concept_id = 3788 and ob.value_coded = 2233 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.person_id in \n ( \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.obs_datetime >= :startDate \n and o.obs_datetime <= :endDate \n ) \n and ob.voided = 0 \n or ob.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Extra Pulmonary TB in ART Intake \n where ob.concept_id = 2236 and ob.value_coded = 2233 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n \n','2023-03-28 16:29:38',4,'2023-03-29 18:36:39',4,0,NULL,NULL,NULL,'5023a0c3-15b8-4d16-ac54-09a77d01648d'),(1863,'HHCM with HIV Positive on CPT/Dapzone','High risk population of HHCM with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM with HIV Positive on CPT/Dapzone\n High risk population of HHCM with HIV Positive on CPT/Dapzone\n \n 2023-03-28 15:05:16 UTC\n \n 2023-03-28 15:09: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 1863\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3777 -- Population (Household member of miner) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 20:35:16',4,'2023-03-28 20:39:54',4,0,NULL,NULL,NULL,'6365d73a-6fde-4e27-a75b-b5010023ddea'),(1864,'New and Relapse with HIV Positive on CPT/Dapzone','High risk population of New and Relapse with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse with HIV Positive on CPT/Dapzone\n High risk population of New and Relapse with HIV Positive on CPT/Dapzone\n \n 2023-03-28 15:14:37 UTC\n \n 2023-03-28 15: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 1864\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded in (1034, 1084) -- Population (New and Relapse) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 20:44:37',4,'2023-03-28 20:46:55',4,0,NULL,NULL,NULL,'14343630-0c58-4f34-8bb5-1744e1618c31'),(1865,'Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : New','Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : New','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : New\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : New\n \n 2023-03-28 15:16:26 UTC\n \n 2023-03-29 16:47: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 1865\n select distinct o.person_id \n FROM obs o \ninner join location l on o.location_id = l.location_id \n -- Bacteriologically confirmed Genotypic test results and Phenotypic test results \n where (o.location_id =:location or parent_location =:location) \n and o.concept_id in (3814, 3815) \n and o.obs_datetime >= :startDate \n and o.obs_datetime <= :endDate \n and o.voided = 0 \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- New Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1034 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n ) \n and o.person_id in ( \n select person_id \n from obs where concept_id = 3789 and value_coded= 3791 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n and o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB \n where ob.concept_id = 3788 and ob.value_coded = 1018 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n or o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB, Bacteriologically Confirmed \n where ob.concept_id = 2236 and ob.value_coded = 2234 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n )\n','2023-03-28 17:16:26',4,'2023-03-29 18:47:04',4,0,NULL,NULL,NULL,'273f38fa-7a41-4323-ac9d-24fd27c0c4cf'),(1866,'Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Relapse','Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Relapse','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Relapse\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Relapse\n \n 2023-03-28 15:21:59 UTC\n \n 2023-03-29 16:47: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 1866\n select distinct o.person_id \n FROM obs o \n \ninner join location l on o.location_id = l.location_id \nWHERE (o.location_id =:location or parent_location =:location) \n and o.concept_id in (3814, 3815) \n and o.obs_datetime >= :startDate \n and o.obs_datetime <= :endDate \n and o.voided = 0 \n AND o.person_id in \n ( \n \n -- Relapsed Clients \n select distinct oo.person_id \n from obs oo \n where oo.concept_id = 3785 and oo.value_coded = 1084 \n and oo.obs_datetime >= :startDate \n and oo.obs_datetime <= :endDate \n ) \n and o.person_id in ( \n select person_id \n from obs where concept_id = 3789 and value_coded= 3791 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n and o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB \n where ob.concept_id = 3788 and ob.value_coded = 1018 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n or o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB, Bacteriologically Confirmed \n where ob.concept_id = 2236 and ob.value_coded = 2234 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n )\n','2023-03-28 17:21:59',4,'2023-03-29 18:47:31',4,0,NULL,NULL,NULL,'300b2de6-1987-4ae2-a742-c2907f6bc2b7'),(1867,'Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Excluding Relapse','Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Excluding Relapse','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Excluding Relapse\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Excluding Relapse\n \n 2023-03-28 15:25:40 UTC\n \n 2023-03-30 15:34: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 1867\n select distinct o.person_id \n FROM obs o \ninner join location l on o.location_id = l.location_id \nWHERE (o.location_id =:location or parent_location =:location) \n and o.concept_id in (3814, 3815) \n and o.obs_datetime >= :startDate \n and o.obs_datetime <= :endDate \n and o.voided = 0 \n AND o.person_id in ( \n select person_id from obs \n where concept_id = 3788 and value_coded = 2233 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n \n ) \n AND o.person_id not in \n ( \n \n -- Relapsed Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1084 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n and o.person_id in ( \n select person_id \n from obs where concept_id = 3789 and value_coded= 3791 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n and o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB \n where ob.concept_id = 3788 and ob.value_coded = 1018 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n or o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB, Bacteriologically Confirmed \n where ob.concept_id = 2236 and ob.value_coded = 2234 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n )\n','2023-03-28 17:25:40',4,'2023-03-30 17:34:09',4,0,NULL,NULL,NULL,'fc1f07c9-e4d5-4d2f-97fb-98b26e6f66d0'),(1868,'Retreatment with HIV Positive on CPT/Dapzone','Retreatment Excl. Relapse with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment with HIV Positive on CPT/Dapzone\n Retreatment Excl. Relapse with HIV Positive on CPT/Dapzone\n \n 2023-03-28 15:28:13 UTC\n \n 2023-03-28 15:30: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 1868\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded in (3786, 1037) -- Population (Retreatment Excl. Relapse) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 20:58:13',4,'2023-03-28 21:00:05',4,0,NULL,NULL,NULL,'fc64e900-ad46-45b3-9514-3d9aaefbd2cf'),(1869,'Children < 15 with Positive HIV on CPT/Dapzone','Children < 15 with Positive HIV on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children < 15 with Positive HIV on CPT/Dapzone\n Children < 15 with Positive HIV on CPT/Dapzone\n \n 2023-03-28 15:51:27 UTC\n \n 2023-03-29 21:44: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 1869\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 \n from obs o \n -- HIV Positive Status \n inner join location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \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 having Age < 15\n','2023-03-28 17:51:27',4,'2023-03-29 23:44:53',4,0,NULL,NULL,NULL,'36fe954a-f05e-431b-9037-4772a4b28383'),(1870,'Miners with HIV Positive on CPT/Dapzone','High risk population Miners with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Miners with HIV Positive on CPT/Dapzone\n High risk population Miners with HIV Positive on CPT/Dapzone\n \n 2023-03-28 15:55:23 UTC\n \n 2023-03-28 15: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 1870\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3667 -- Population (miner) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 21:25:23',4,'2023-03-28 21:26:49',4,0,NULL,NULL,NULL,'354da83b-27c3-4124-9198-d1902fefb417'),(1871,'Ex Miner with HIV Positive on CPT/Dapzone',' High risk population of Ex Miner with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex Miner with HIV Positive on CPT/Dapzone\n High risk population of Ex Miner with HIV Positive on CPT/Dapzone\n \n 2023-03-28 16:02:40 UTC\n \n 2023-03-28 16:06: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 1871\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3668 -- Population (Ex miner) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 21:32:40',4,'2023-03-28 21:36:28',4,0,NULL,NULL,NULL,'ff703f75-36cc-4487-afab-65df0ccbff68'),(1872,'Factory Workers with HIV Positive on CPT/Dapzone','High risk population of Factory Workers with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Workers with HIV Positive on CPT/Dapzone\n High risk population of Factory Workers with HIV Positive on CPT/Dapzone\n \n 2023-03-28 16:08:16 UTC\n \n 2023-03-28 16:09: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 1872\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3770 -- Population (Factory Workers) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 21:38:16',4,'2023-03-28 21:39:25',4,0,NULL,NULL,NULL,'ff030c28-e12b-45ed-80b0-330e353fdd29'),(1873,'Public transport operators with HIV Positive on CPT/Dapzone','High risk population of Public transport operators with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public transport operators with HIV Positive on CPT/Dapzone\n High risk population of Public transport operators with HIV Positive on CPT/Dapzone\n \n 2023-03-28 16:14:01 UTC\n \n 2023-03-28 16:14: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 1873\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =4654 -- Population (Public transport operators) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 21:44:01',4,'2023-03-28 21:44:45',4,0,NULL,NULL,NULL,'b116d4a0-174f-49a7-be0f-3d5f79581b05'),(1874,'Health workers with HIV Positive on CPT/Dapzone',' High risk population of Health workers with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health workers with HIV Positive on CPT/Dapzone\n High risk population of Health workers with HIV Positive on CPT/Dapzone\n \n 2023-03-28 16:16:21 UTC\n \n 2023-03-28 16:17: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 1874\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3470 -- Population (Health workers) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 21:46:21',4,'2023-03-28 21:47:38',4,0,NULL,NULL,NULL,'4c4aa324-1728-4001-a94e-e857574126b1'),(1875,'Correctional Staff and inmates with HIV Positive on CPT/Dapzone','High risk population of Correctional Staff and inmates with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Correctional Staff and inmates with HIV Positive on CPT/Dapzone\n High risk population of Correctional Staff and inmates with HIV Positive on CPT/Dapzone\n \n 2023-03-28 16:20:31 UTC\n \n 2023-03-28 16:27: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 1875\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded in (3779, 3671) -- Population (Correctional Staff and inmates) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 21:50:31',4,'2023-03-28 21:57:26',4,0,NULL,NULL,NULL,'423a7240-f359-41a2-929d-7b1cd7010807'),(1876,'TB among Miners','TB among Key Population Group Miners','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Miners\n TB among Key Population Group Miners\n \n 2023-03-28 17:11:27 UTC\n \n 2023-03-28 17:34: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 1876\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- Miners \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- Miners \n select distinct person_id \n from obs \n where concept_id = 3776 and value_coded = 3667 \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) AS Miner \n)\n','2023-03-28 22:41:27',4,'2023-03-28 23:04:23',4,0,NULL,NULL,NULL,'273e3515-f928-4164-be82-fc5235d66188'),(1877,'TB among Exminers','TB among Key Population Group Exminers','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Exminers\n TB among Key Population Group Exminers\n \n 2023-03-28 17:40:01 UTC\n \n 2023-03-28 17: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 1877\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- Exminers \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- Exminers \n select distinct person_id \n from obs \n where concept_id = 3776 and value_coded = 3668 \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) AS Exminer \n)\n','2023-03-28 23:10:01',4,'2023-03-28 23:11:15',4,0,NULL,NULL,NULL,'ecb47cb2-6af4-4932-8fee-076ba40afa87'),(1878,'TB among HHCM','TB among Key Population Group HHCM','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among HHCM\n TB among Key Population Group HHCM\n \n 2023-03-28 19:19:59 UTC\n \n 2023-03-28 19:26: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 1878\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- HHCM \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- HHCM \n select distinct person_id \n from obs \n where concept_id = 3776 and value_coded = 3777 \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) As HHCM \n)\n','2023-03-29 00:49:59',4,'2023-03-29 00:56:17',4,0,NULL,NULL,NULL,'0da939c1-ae87-45c8-80ed-e56b82e5a62e'),(1879,'Correctional Staff and inmates on HIV Positive on ART','High risk population of Correctional Staff and inmates on HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Correctional Staff and inmates on HIV Positive on ART\n High risk population of Correctional Staff and inmates on HIV Positive on ART\n \n 2023-03-28 19:25:59 UTC\n \n 2023-03-29 20: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 1879\n select distinct o.person_id \n from obs o \n -- On ART \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded in (3779, 3671) -- Population (Correctional Staff and inmates) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \nAND o.obs_datetime >= CAST(:endDate AS DATE) \n\n','2023-03-28 21:25:59',4,'2023-03-29 22:58:43',4,0,NULL,NULL,NULL,'a6ebd7a8-631b-4e0e-bdfb-8be1b9fb9eec'),(1880,'New and Relapse with HIV Positive on ART','High risk population of New and Relapse with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse with HIV Positive on ART\n High risk population of New and Relapse with HIV Positive on ART\n \n 2023-03-28 19:29:52 UTC\n \n 2023-03-28 19:32: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 1880\n SELECT DISTINCT o.person_id \n from obs o \n -- New and Relapse On ART \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3785 and ob.value_coded in (1034, 1084) -- New and Relapse \n and ob.voided = 0 \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE)\n','2023-03-29 00:59:52',4,'2023-03-29 01:02:02',4,0,NULL,NULL,NULL,'8067c849-4c81-475a-a26e-68a2e58b8067'),(1882,'Retreatment with HIV Positive on ART','High risk population of Retreatment Excl. Relapse HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment with HIV Positive on ART\n High risk population of Retreatment Excl. Relapse HIV Positive on ART\n \n 2023-03-28 19:34:51 UTC\n \n 2023-03-28 19:45: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 1882\n SELECT DISTINCT o.person_id \n from obs o \n -- Retreatmentafter LTFU/Failure on ART \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3785 and ob.value_coded in (3786, 1037) -- Retreatmentafter LTFU/Failure \n and ob.voided = 0 \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-29 01:04:51',4,'2023-03-29 01:15:46',4,0,NULL,NULL,NULL,'fe4f73c9-4b24-4458-9ae1-9d3fcad9f9cb'),(1883,'TB among HHXM','TB among Key Population Group HHXM','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among HHXM\n TB among Key Population Group HHXM\n \n 2023-03-28 19:35:03 UTC\n \n 2023-03-28 19:37: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 1883\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- HHXM \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- HHXM \n select distinct person_id \n from obs \n where concept_id = 3776 and value_coded = 3778 \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) AS HHXM \n)\n','2023-03-29 01:05:03',4,'2023-03-29 01:07:06',4,0,NULL,NULL,NULL,'4715bb07-7b64-4001-b5cb-ea555b425a07'),(1884,'TB among Factory Workers','TB among Key Population Group Factory Workers','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Factory Workers\n TB among Key Population Group Factory Workers\n \n 2023-03-28 19:43:14 UTC\n \n 2023-03-28 19:45:00 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 1884\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- FactoryWorkers \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- FactoryWorkers \n select distinct person_id \n from obs \n where concept_id = 3776 and value_coded = 3669 \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) AS FactoryWorkers \n)\n','2023-03-29 01:13:14',4,'2023-03-29 01:15:01',4,0,NULL,NULL,NULL,'6bed2c03-ba40-477b-9a9a-67f3fcd50ea3'),(1885,'TB among Correctional Staff & Inmates','TB among Key Population Group Correctional Staff & Inmates','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Correctional Staff & Inmates\n TB among Key Population Group Correctional Staff & Inmates\n \n 2023-03-28 19:47:06 UTC\n \n 2023-03-28 19:49: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 1885\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- Correctional Staff & Inmates \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- Correctional Staff & Inmates \n select distinct person_id \n from obs \n where concept_id = 3776 and value_coded in (3779,3671) \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) AS Correctional \n)\n','2023-03-29 01:17:06',4,'2023-03-29 01:19:30',4,0,NULL,NULL,NULL,'9016d0ef-4556-49e7-99bd-2bf2e7f5188f'),(1886,'Children < 15 with HIV Positive on ART','High risk population for Children < 15 with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children < 15 with HIV Positive on ART\n High risk population for Children < 15 with HIV Positive on ART\n \n 2023-03-28 19:47:46 UTC\n \n 2023-03-28 19:50: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 1886\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 \n from obs o \n -- HIV Positive on ART \n inner join location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \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 having Age < 15\n','2023-03-29 01:17:46',4,'2023-03-29 01:20:02',4,0,NULL,NULL,NULL,'e724e30e-b9e1-4a19-afa9-d19aa8dc42f4'),(1887,'TB among Public Transport Operators ','TB among Key Population Group Public Transport Operators','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Public Transport Operators \n TB among Key Population Group Public Transport Operators\n \n 2023-03-28 19:51:36 UTC\n \n 2023-03-28 19:53: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 1887\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- Transport \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- Transport \n select distinct person_id \n from obs \n where concept_id = 3776 and value_coded = 4654 \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) AS Transport \n)\n','2023-03-29 01:21:36',4,'2023-03-29 01:23:32',4,0,NULL,NULL,NULL,'4aac5017-e28a-4f36-8805-0812476a9d7b'),(1888,'Miners with HIV Positive on ART','High risk population of Miners with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Miners with HIV Positive on ART\n High risk population of Miners with HIV Positive on ART\n \n 2023-03-28 19:55:27 UTC\n \n 2023-03-28 19:56: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 1888\n select distinct o.person_id \n from obs o \n -- HIV Positive on ART \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3667 -- Population (Miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-29 01:25:27',4,'2023-03-29 01:26:16',4,0,NULL,NULL,NULL,'a37a95b7-1365-4d73-8d21-28dd2e77196e'),(1889,'TB among Health Workers','TB among Key Population Group Health Workers','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Health Workers\n TB among Key Population Group Health Workers\n \n 2023-03-28 19:55:49 UTC\n \n 2023-03-28 19:57: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 1889\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- HealthWorkers \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- HealthWorkers \n select distinct person_id \n from obs \n where concept_id = 3776 and value_coded = 3670 \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) AS HealthWorkers \n)\n','2023-03-29 01:25:49',4,'2023-03-29 01:27:20',4,0,NULL,NULL,NULL,'04590a3f-4e59-45fe-a5c3-f5ae76ef805b'),(1890,'Ex Miner with with HIV Positive on ART','High risk population of Ex Miner with with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex Miner with with HIV Positive on ART\n High risk population of Ex Miner with with HIV Positive on ART\n \n 2023-03-28 19:58:00 UTC\n \n 2023-03-28 19:59: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 1890\n select distinct o.person_id \n from obs o \n -- HIV Positive on ART \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3668 -- Population (Ex-Miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-29 01:28:00',4,'2023-03-29 01:29:01',4,0,NULL,NULL,NULL,'1edf0f21-2fad-48c7-a24a-e21367f334c1'),(1891,'HHCM with with HIV Positive on ART','High risk population of HHCM with with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM with with HIV Positive on ART\n High risk population of HHCM with with HIV Positive on ART\n \n 2023-03-28 20:00:28 UTC\n \n 2023-03-28 20:03: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 1891\n select distinct o.person_id \n from obs o \n -- HIV Positive on ART \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3777 -- Population (Household member of current miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-29 01:30:28',4,'2023-03-29 01:33:58',4,0,NULL,NULL,NULL,'14b8879f-49ef-492c-aeb0-fdd62fde084a'),(1892,'TB among Miners','TB among Key Population Group Miners','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Miners\n TB among Key Population Group Miners\n \n 2023-03-28 20:05:03 UTC\n \n 2023-03-28 20:12: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 1892\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 01:35:03',4,'2023-03-29 01:42:22',4,0,NULL,NULL,NULL,'526100b3-2b2a-4f15-862e-4be06d73bdb3'),(1893,'HHXM with HIV Positive on ART','High risk population of HHXM with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM with HIV Positive on ART\n High risk population of HHXM with HIV Positive on ART\n \n 2023-03-28 20:05:19 UTC\n \n 2023-03-28 20: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 1893\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3778 -- Population (Household member of Ex miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-29 01:35:19',4,'2023-03-29 01:38:02',4,0,NULL,NULL,NULL,'0d7e9652-b8fa-4264-859b-0b681452c462'),(1894,'Factory Workers with HIV Positive on ART','High risk population of Factory Workers with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Workers with HIV Positive on ART\n High risk population of Factory Workers with HIV Positive on ART\n \n 2023-03-28 20:09:30 UTC\n \n 2023-03-28 20:10: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 1894\n select distinct o.person_id \n from obs o \n -- Positive HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3669 -- Population (Factory Workers) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-29 01:39:30',4,'2023-03-29 01:40:27',4,0,NULL,NULL,NULL,'67233a82-27bf-4615-948b-28fad7ad6322'),(1895,'Public transport operators with HIV Positive on ART','High risk population of Public transport operators with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public transport operators with HIV Positive on ART\n High risk population of Public transport operators with HIV Positive on ART\n \n 2023-03-28 20:12:15 UTC\n \n 2023-03-28 20:14: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 1895\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 4654 -- Population (Public transport operators) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-29 01:42:15',4,'2023-03-29 01:44:34',4,0,NULL,NULL,NULL,'63418340-29fe-4106-83ad-a09538397f5f'),(1896,'TB among Exminers','TB among Key Population Group Ex Miners','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Exminers\n TB among Key Population Group Ex Miners\n \n 2023-03-28 20:13:33 UTC\n \n 2023-03-28 20: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 1896\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 01:43:33',4,'2023-03-29 01:48:09',4,0,NULL,NULL,NULL,'2dcbfff3-70b6-4ed5-b727-a51fea71b8aa'),(1897,'Health workers with HIV Positive on ART','High risk population of Health workers with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health workers with HIV Positive on ART\n High risk population of Health workers with HIV Positive on ART\n \n 2023-03-28 20:18:06 UTC\n \n 2023-03-28 20:18: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 1897\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 4670 -- Population (Health workers) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-29 01:48:06',4,'2023-03-29 01:48:39',4,0,NULL,NULL,NULL,'1340548d-896a-4473-ae26-4c8960dec630'),(1898,'TB among HHCM','TB among Key Population Group HHCM','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among HHCM\n TB among Key Population Group HHCM\n \n 2023-03-28 20:19:17 UTC\n \n 2023-03-28 20:20: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 1898\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 01:49:17',4,'2023-03-29 01:50:21',4,0,NULL,NULL,NULL,'dd0ada55-f903-426e-a60e-f83ceeb15cab'),(1899,'TB among HHXM','TB among Key Population Group HHXM','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among HHXM\n TB among Key Population Group HHXM\n \n 2023-03-28 20:21:08 UTC\n \n 2023-03-28 20:23: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 1899\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 01:51:08',4,'2023-03-29 01:53:24',4,0,NULL,NULL,NULL,'9558eb96-47f5-4cdd-ad4f-d07257529259'),(1900,'Pulmonary Bacteriologically Confirmed - Exlude Relapse','Pulmonary Bacteriologically Confirmed - Exlude Relapse','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Bacteriologically Confirmed - Exlude Relapse\n Pulmonary Bacteriologically Confirmed - Exlude Relapse\n \n 2023-03-29 03:39:55 UTC\n \n 2023-03-29 17:21: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 1900\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 05:39:55',4,'2023-03-29 19:21:25',4,0,NULL,NULL,NULL,'8315a536-5b6e-4da8-bcf7-860b6b6bd8aa'),(1902,'Pulmonary Bacteriologically Confirmed New','Pulmonary Bacteriologically Confirmed New','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Bacteriologically Confirmed New\n Pulmonary Bacteriologically Confirmed New\n \n 2023-03-29 04:12:11 UTC\n \n 2023-03-29 05:37: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 1902\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 09:42:11',4,'2023-03-29 11:07:28',4,0,NULL,NULL,NULL,'15e06979-0f27-4aba-87fb-bc5a6dc28da4'),(1903,'Pulmonary Clinically Diagnosed Excluding Relapse','Pulmonary Clinically Diagnosed Excluding Relapse','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Clinically Diagnosed Excluding Relapse\n Pulmonary Clinically Diagnosed Excluding Relapse\n \n 2023-03-29 06:06:35 UTC\n \n 2023-03-29 08:12: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 1903\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 11:36:35',4,'2023-03-29 13:42:28',4,0,NULL,NULL,NULL,'b0ff3ba5-25df-46e4-8eae-bfca7d86b9dd'),(1904,'Pulmonary Bacteriologically Confirmed Relapse','Pulmonary Bacteriologically Confirmed Relapse','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Bacteriologically Confirmed Relapse\n Pulmonary Bacteriologically Confirmed Relapse\n \n 2023-03-29 06:08:27 UTC\n \n 2023-03-29 08:11: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 1904\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 11:38:27',4,'2023-03-29 13:41:19',4,0,NULL,NULL,NULL,'f6797c59-e7e3-4492-ad5f-a67bf5e683bc'),(1905,'Pulmonary Clinically Diagnosed New','Pulmonary Clinically Diagnosed New','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Clinically Diagnosed New\n Pulmonary Clinically Diagnosed New\n \n 2023-03-29 08:14:51 UTC\n \n 2023-03-29 08:17: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 1905\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 13:44:51',4,'2023-03-29 13:47:31',4,0,NULL,NULL,NULL,'63333694-f766-4047-830b-087496f8e5a8'),(1906,'Pulmonary Clinically Diagnosed Relapse','Pulmonary Clinically Diagnosed Relapse','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Clinically Diagnosed Relapse\n Pulmonary Clinically Diagnosed Relapse\n \n 2023-03-29 08:15:08 UTC\n \n 2023-03-29 08: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 1906\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 13:45:08',4,'2023-03-29 13:48:31',4,0,NULL,NULL,NULL,'2ff007c1-993d-48fc-8df6-9ed7c66b42d3'),(1907,'Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - New','Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - New','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - New\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - New\n \n 2023-03-29 08:25:10 UTC\n \n 2023-03-29 08:49: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 1907\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 13:55:10',4,'2023-03-29 14:19:47',4,0,NULL,NULL,NULL,'d1ce1a2c-338a-4926-a1d4-f7f79ac2b875'),(1908,'TB among Factory Workers','TB among Key Population Group Factory Workers','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Factory Workers\n TB among Key Population Group Factory Workers\n \n 2023-03-29 08:26:00 UTC\n \n 2023-03-29 08:52: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 1908\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-03-29 13:56:00',4,'2023-03-29 14:22:40',4,0,NULL,NULL,NULL,'071a7d7a-f944-4965-978c-bfe740051b9a'),(1909,'Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Relapse','Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Relapse','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Relapse\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Relapse\n \n 2023-03-29 08:52:39 UTC\n \n 2023-03-29 08:54: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 1909\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 14:22:39',4,'2023-03-29 14:24:28',4,0,NULL,NULL,NULL,'20c9a6fc-f845-4569-b018-b5f59c39948c'),(1910,'Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Excluging Relapse','Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Excluging Relapse','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Excluging Relapse\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Excluging Relapse\n \n 2023-03-29 08:53:19 UTC\n \n 2023-03-29 08:54: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 1910\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 14:23:19',4,'2023-03-29 14:24:54',4,0,NULL,NULL,NULL,'422afe85-5763-4700-8a8b-bf17328901a8'),(1911,'TB among Correctional Staff & Inmates','TB among Key Population Group Correctional Staff & Inmates','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Correctional Staff & Inmates\n TB among Key Population Group Correctional Staff & Inmates\n \n 2023-03-29 08:53:58 UTC\n \n 2023-03-29 08:56: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 1911\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 14:23:58',4,'2023-03-29 14:26:06',4,0,NULL,NULL,NULL,'8ac11f64-421a-4f48-9ac3-048ee6912eda'),(1912,'Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Excluding Relapse','Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Excluding Relapse','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Excluding Relapse\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Excluding Relapse\n \n 2023-03-29 08:55:36 UTC\n \n 2023-03-29 09:04: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 1912\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 14:25:36',4,'2023-03-29 14:34:23',4,0,NULL,NULL,NULL,'83125cb9-0324-4e21-8f4d-b9fd51049909'),(1913,'TB among Public Transport Operators ','TB among Key Population Group Public Transport Operators','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Public Transport Operators \n TB among Key Population Group Public Transport Operators\n \n 2023-03-29 08:57:05 UTC\n \n 2023-03-29 08:59: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 1913\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 14:27:05',4,'2023-03-29 14:29:07',4,0,NULL,NULL,NULL,'f3aabc74-880c-4502-94af-ff9fd0b95906'),(1914,'Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : New','Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : New','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : New\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : New\n \n 2023-03-29 08:59:37 UTC\n \n 2023-03-29 09:04: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 1914\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 14:29:37',4,'2023-03-29 14:34:54',4,0,NULL,NULL,NULL,'c5e34544-e98f-42ce-82d1-3708ce5e5b80'),(1915,'TB among Health Workers','TB among Key Population Group Health Workers','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Health Workers\n TB among Key Population Group Health Workers\n \n 2023-03-29 09:02:15 UTC\n \n 2023-03-29 09: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 1915\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 14:32:15',4,'2023-03-29 14:34:59',4,0,NULL,NULL,NULL,'76adf56b-486f-4a4c-b309-5c43372d94eb'),(1916,'TB Notification - Block 3','TB Notification - Block 3','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Notification - Block 3\n TB Notification - Block 3\n \n 2023-03-29 09:08:01 UTC\n \n 2023-03-29 09:08: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 1916\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-03-29 14:38:01',4,'2023-03-29 14:38:31',4,0,NULL,NULL,NULL,'5a51f412-3b6f-4808-ae32-ed90141bb7e2'),(1917,'TB Notification - Block 3 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 Notification - Block 3 Data Set\n \n 2023-03-29 09:08:31 UTC\n \n 2023-03-29 10: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 1917\n \n \n \n TB-HHCM\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 TB-HHXM\n \n \n \n \n \n \n \n \n \n TBExMiners\n \n \n \n \n \n \n \n \n \n TBFactoryW\n \n \n \n \n \n \n \n \n \n TBHealthW\n \n \n \n \n \n \n \n \n \n TBInmates\n \n \n \n \n \n \n \n \n \n TBMiners\n \n \n \n \n \n \n \n \n \n TBTrans\n \n \n \n \n \n \n \n \n \n','2023-03-29 14:38:31',4,'2023-03-29 15:38:22',4,0,NULL,NULL,NULL,'4e91ef91-ad5f-4717-b782-9ac61d52dc40'),(1919,'Block 1: All TB Patients diagnosed with TB during the current quarter, by history of treatment and anatomic site of disease Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Block 1: All TB Patients diagnosed with TB during the current quarter, by history of treatment and anatomic site of disease Data Set\n \n 2023-03-29 09:46:48 UTC\n \n 2023-03-29 15:30: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 1919\n \n \n \n died1\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 died2\n \n \n \n \n \n \n \n \n \n died3\n \n \n \n \n \n \n \n \n \n extra1\n \n \n \n \n \n \n \n \n \n extra2\n \n \n \n \n \n \n \n \n \n extra3\n \n \n \n \n \n \n \n \n \n pul_ExPulm\n \n \n \n \n \n \n \n \n \n pul_clin1\n \n \n \n \n \n \n \n \n \n pul_diag2\n \n \n \n \n \n \n \n \n \n pul_new \n \n \n \n \n \n \n \n \n \n pul_newex\n \n \n \n \n \n \n \n \n \n pul_relaps\n \n \n \n \n \n \n \n \n \n','2023-03-29 11:46:48',4,'2023-03-29 17:30:32',4,0,NULL,NULL,NULL,'b7c3203a-888a-4139-9c3f-e9a8939bc811'),(1920,'New and Relapse with document HIV Status','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse with document HIV Status\n \n \n 2023-03-29 14:22:45 UTC\n \n 2023-03-29 14:30: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 1920\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 19:52:45',4,'2023-03-29 20:00:02',4,0,NULL,NULL,NULL,'18152a92-ded2-4f5a-af93-5dd01b51c839'),(1921,'Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Relapse','Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Relapse','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Relapse\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Relapse\n \n 2023-03-29 15:26:50 UTC\n \n 2023-03-29 15:28: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 1921\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 17:26:50',4,'2023-03-29 17:28:11',4,0,NULL,NULL,NULL,'61cb2cc7-ee32-4da9-9c82-7bbc85f3e43c'),(1922,'TB Notification - Block 1 ','TB Notification - Block 1 ','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Notification - Block 1 \n TB Notification - Block 1 \n \n 2023-03-29 17:06:10 UTC\n \n 2023-03-29 17:06: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 1922\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-03-29 19:06:10',4,'2023-03-29 19:06:58',4,0,NULL,NULL,NULL,'c7604f80-13cf-4773-abf5-b95f35fa1c92'),(1923,'TB Notification - 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 Notification - Block 1 Data Set\n \n 2023-03-29 17:06:58 UTC\n \n 2023-03-29 17:37: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 1923\n \n \n \n died1\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 died2\n \n \n \n \n \n \n \n \n \n died3\n \n \n \n \n \n \n \n \n \n extra1\n \n \n \n \n \n \n \n \n \n extra2\n \n \n \n \n \n \n \n \n \n extra3\n \n \n \n \n \n \n \n \n \n pul1\n \n \n \n \n \n \n \n \n \n pul2\n \n \n \n \n \n \n \n \n \n pul3\n \n \n \n \n \n \n \n \n \n','2023-03-29 19:06:58',4,'2023-03-29 19:37:54',4,0,NULL,NULL,NULL,'d74aa49a-aa20-49e1-939a-5f1fb0c78d81'),(1924,'Children < 15 with Documented HIV Status','Children (0 - 14) with documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children < 15 with Documented HIV Status\n Children (0 - 14) with documented HIV Status\n \n 2023-03-29 17:07:40 UTC\n \n 2023-03-29 17:08: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 1924\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-03-29 19:07:40',4,'2023-03-29 19:08:45',4,0,NULL,NULL,NULL,'777854f8-1e75-4b4c-9eb5-2b2a23acd1fd'),(1925,'Correctional Staff and inmates with Documented HIV Status','High risk population of Correctional Staff and inmates with Documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Correctional Staff and inmates with Documented HIV Status\n High risk population of Correctional Staff and inmates with Documented HIV Status\n \n 2023-03-29 17:11:52 UTC\n \n 2023-03-29 17:16: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 1925\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 19:11:52',4,'2023-03-29 19:16:20',4,0,NULL,NULL,NULL,'8e2ae589-9a13-4aa5-bf9d-3cf376a59bf6'),(1926,'Ex-Miners with Documented HIV Status','High risk population of Ex Miners with Documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex-Miners with Documented HIV Status\n High risk population of Ex Miners with Documented HIV Status\n \n 2023-03-29 17:20:28 UTC\n \n 2023-03-29 17:23: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 1926\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 19:20:28',4,'2023-03-29 19:23:06',4,0,NULL,NULL,NULL,'b2541e20-b6b8-4985-bd4a-9a980ee5ebf8'),(1927,'Factory Workers with Documented HIV Status','High risk population of Factory Workers with Documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Workers with Documented HIV Status\n High risk population of Factory Workers with Documented HIV Status\n \n 2023-03-29 17:25:11 UTC\n \n 2023-03-29 17:29: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 1927\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 19:25:11',4,'2023-03-29 19:29:17',4,0,NULL,NULL,NULL,'e95e9d48-01d5-4826-ab2c-82dbd2dfce44'),(1928,'Health workers with Documented HIV Status','High risk population of Health workers with Documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health workers with Documented HIV Status\n High risk population of Health workers with Documented HIV Status\n \n 2023-03-29 17:31:28 UTC\n \n 2023-03-29 17:33: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 1928\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 19:31:28',4,'2023-03-29 19:33:36',4,0,NULL,NULL,NULL,'38dd8693-21f8-40c2-ba3a-9f5d1a63959c'),(1929,'HHCM with Documented HIV Status','High risk population of HHCM with Documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM with Documented HIV Status\n High risk population of HHCM with Documented HIV Status\n \n 2023-03-29 17:34:59 UTC\n \n 2023-03-29 17:36: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 1929\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 19:34:59',4,'2023-03-29 19:36:32',4,0,NULL,NULL,NULL,'12a86c02-9e39-4d69-8082-ecff9269d106'),(1930,'Miners with Documented HIV Status','High risk population of miners with documented HIV','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Miners with Documented HIV Status\n High risk population of miners with documented HIV\n \n 2023-03-29 17:39:04 UTC\n \n 2023-03-29 17: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 1930\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 19:39:04',4,'2023-03-29 19:42:27',4,0,NULL,NULL,NULL,'625cc3fd-4dc5-4aee-9fba-2559b31470c8'),(1931,'Public transport operators with Documented HIV Status','High risk population of Public transport operators with Documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public transport operators with Documented HIV Status\n High risk population of Public transport operators with Documented HIV Status\n \n 2023-03-29 19:32:07 UTC\n \n 2023-03-29 19: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 1931\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 21:32:07',4,'2023-03-29 21:33:35',4,0,NULL,NULL,NULL,'9e48b5ef-99df-44e7-8946-2728727e08a1'),(1932,'Retreatment with documented HIV status','Retreatment Excl. Relapse client with documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment with documented HIV status\n Retreatment Excl. Relapse client with documented HIV Status\n \n 2023-03-29 19:35:36 UTC\n \n 2023-03-29 19:36: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 1932\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 21:35:36',4,'2023-03-29 21:36:55',4,0,NULL,NULL,NULL,'5cc834ec-7c90-4063-b684-2c9da8ddc83e'),(1933,'Children < 15 with Positive HIV Status','High risk population for Children < 15 with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children < 15 with Positive HIV Status\n High risk population for Children < 15 with Positive HIV Status\n \n 2023-03-29 19:40:57 UTC\n \n 2023-03-29 19:42: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 1933\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 21:40:57',4,'2023-03-29 21:42:25',4,0,NULL,NULL,NULL,'9ceb1ec0-0b28-49d8-a6ba-90297cae2968'),(1934,'Correctional Staff and inmates with Positive HIV Status',' High risk population of Correctional Staff and inmates with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Correctional Staff and inmates with Positive HIV Status\n High risk population of Correctional Staff and inmates with Positive HIV Status\n \n 2023-03-29 19:44:28 UTC\n \n 2023-03-29 19:45: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 1934\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 21:44:28',4,'2023-03-29 21:45:44',4,0,NULL,NULL,NULL,'c9be5185-942d-41ae-8e15-c3ddea7bb22f'),(1935,'Ex-Miners with Positive HIV Status','High risk population of Ex Miners with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex-Miners with Positive HIV Status\n High risk population of Ex Miners with Positive HIV Status\n \n 2023-03-29 19:47:14 UTC\n \n 2023-03-29 19:50: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 1935\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 21:47:14',4,'2023-03-29 21:50:01',4,0,NULL,NULL,NULL,'51933c5f-9020-417a-91fe-77cb0412d9ee'),(1936,'Factory Workers with Positive HIV Status','High risk population of Factory Workers with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Workers with Positive HIV Status\n High risk population of Factory Workers with Positive HIV Status\n \n 2023-03-29 19:52:48 UTC\n \n 2023-03-29 19:56: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 1936\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 21:52:48',4,'2023-03-29 21:56:43',4,0,NULL,NULL,NULL,'a72725b5-eac8-4f97-b285-3a9db174ab39'),(1937,'Health workers with Positive HIV Status',' High risk population of Health workers with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health workers with Positive HIV Status\n High risk population of Health workers with Positive HIV Status\n \n 2023-03-29 19:59:20 UTC\n \n 2023-03-29 20:04: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 1937\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 21:59:20',4,'2023-03-29 22:04:12',4,0,NULL,NULL,NULL,'317c0cce-c0d7-44da-9272-62cc9279a76c'),(1938,'HHCM with Positive HIV Status',' High risk population of HHCM with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM with Positive HIV Status\n High risk population of HHCM with Positive HIV Status\n \n 2023-03-29 20:05:19 UTC\n \n 2023-03-29 20:09: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 1938\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 22:05:19',4,'2023-03-29 22:09:51',4,0,NULL,NULL,NULL,'7a7dee7e-a318-4819-96e9-a1c8fe3e0a4f'),(1939,'HHXM with Positive HIV Status','High risk population of HHXM with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM with Positive HIV Status\n High risk population of HHXM with Positive HIV Status\n \n 2023-03-29 20:10:54 UTC\n \n 2023-03-29 20:11: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 1939\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 22:10:54',4,'2023-03-29 22:11:59',4,0,NULL,NULL,NULL,'4a4bc063-3233-4b3f-9776-8949a2a3104c'),(1940,'Miners with Positive HIV Status','High risk population of miners with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Miners with Positive HIV Status\n High risk population of miners with Positive HIV Status\n \n 2023-03-29 20:13:09 UTC\n \n 2023-03-29 20:15: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 1940\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 22:13:09',4,'2023-03-29 22:15:52',4,0,NULL,NULL,NULL,'a555cd0b-41bf-4ba0-bc0a-bb84952305d7'),(1941,'New and Relapse with Positive HIV Status','New and Relapse with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse with Positive HIV Status\n New and Relapse with Positive HIV Status\n \n 2023-03-29 20:17:12 UTC\n \n 2023-03-29 20:37: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 1941\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 22:17:12',4,'2023-03-29 22:37:39',4,0,NULL,NULL,NULL,'5212b24d-abdf-416a-812e-72b4f64b342d'),(1942,'Public transport with Positive HIV Status','High risk population of Public transport operators with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public transport with Positive HIV Status\n High risk population of Public transport operators with Positive HIV Status\n \n 2023-03-29 20:38:50 UTC\n \n 2023-03-29 20:39: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 1942\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 22:38:50',4,'2023-03-29 22:39:44',4,0,NULL,NULL,NULL,'3ada2309-e8f6-4301-ae89-63837fb6f36b'),(1943,'Retreatment with Positive HIV status','Retreatment Excl. Relapse with Positive HIV status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment with Positive HIV status\n Retreatment Excl. Relapse with Positive HIV status\n \n 2023-03-29 20:41:12 UTC\n \n 2023-03-29 20:42: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 1943\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 22:41:12',4,'2023-03-29 22:42:06',4,0,NULL,NULL,NULL,'ee1b5901-9777-44c1-affd-37e3aba4746a'),(1944,'Children < 15 with HIV Positive on ART','High risk population for Children < 15 with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children < 15 with HIV Positive on ART\n High risk population for Children < 15 with HIV Positive on ART\n \n 2023-03-29 20:43:47 UTC\n \n 2023-03-29 20:55: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 1944\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 22:43:47',4,'2023-03-29 22:55:26',4,0,NULL,NULL,NULL,'f636be9d-0527-4054-9822-6ab005267560'),(1945,'Correctional Staff and inmates on HIV Positive on ART','High risk population of Correctional Staff and inmates on HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Correctional Staff and inmates on HIV Positive on ART\n High risk population of Correctional Staff and inmates on HIV Positive on ART\n \n 2023-03-29 20:56:54 UTC\n \n 2023-03-29 20: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 1945\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 22:56:54',4,'2023-03-29 22:59:44',4,0,NULL,NULL,NULL,'2c07cd7e-cc23-4974-9964-602e576ef80d'),(1946,'Ex Miner with with HIV Positive on ART','High risk population of Ex Miner with with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex Miner with with HIV Positive on ART\n High risk population of Ex Miner with with HIV Positive on ART\n \n 2023-03-29 21:01:08 UTC\n \n 2023-03-29 21:05: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 1946\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:01:08',4,'2023-03-29 23:05:53',4,0,NULL,NULL,NULL,'8df71093-9cb8-4d1d-9885-fb4415f8c1b2'),(1947,'Factory Workers with HIV Positive on ART','High risk population of Factory Workers with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Workers with HIV Positive on ART\n High risk population of Factory Workers with HIV Positive on ART\n \n 2023-03-29 21:07:39 UTC\n \n 2023-03-29 21:11: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 1947\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:07:39',4,'2023-03-29 23:11:51',4,0,NULL,NULL,NULL,'6d1a75ee-e860-483d-ad80-4308d1009c22'),(1948,'Health workers with HIV Positive on ART',' High risk population of Health workers with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health workers with HIV Positive on ART\n High risk population of Health workers with HIV Positive on ART\n \n 2023-03-29 21:13:26 UTC\n \n 2023-03-29 21:17: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 1948\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:13:26',4,'2023-03-29 23:17:08',4,0,NULL,NULL,NULL,'b3813228-7114-4e37-b997-6acebccd724a'),(1949,'HHCM with with HIV Positive on ART','High risk population of HHCM with with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM with with HIV Positive on ART\n High risk population of HHCM with with HIV Positive on ART\n \n 2023-03-29 21:18:20 UTC\n \n 2023-03-29 21:19: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 1949\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:18:20',4,'2023-03-29 23:19:22',4,0,NULL,NULL,NULL,'360494e1-ccad-4e72-bf80-c564f2cfe18b'),(1950,'HHXM with HIV Positive on ART','High risk population of HHXM with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM with HIV Positive on ART\n High risk population of HHXM with HIV Positive on ART\n \n 2023-03-29 21:20:51 UTC\n \n 2023-03-29 21:25: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 1950\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:20:51',4,'2023-03-29 23:25:50',4,0,NULL,NULL,NULL,'ce4eaae7-7985-4e89-ab65-3b0c1686f80e'),(1951,'Miners with HIV Positive on ART','High risk population of Miners with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Miners with HIV Positive on ART\n High risk population of Miners with HIV Positive on ART\n \n 2023-03-29 21:27:27 UTC\n \n 2023-03-29 21:30: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 1951\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:27:27',4,'2023-03-29 23:30:27',4,0,NULL,NULL,NULL,'19d13a38-7625-4136-b870-a7facc92ecb3'),(1952,'New and Relapse with HIV Positive on ART','High risk population of New and Relapse with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse with HIV Positive on ART\n High risk population of New and Relapse with HIV Positive on ART\n \n 2023-03-29 21:33:41 UTC\n \n 2023-03-29 21:36: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 1952\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:33:41',4,'2023-03-29 23:36:00',4,0,NULL,NULL,NULL,'86db5b09-049a-4be4-a35f-f02f9de644f6'),(1953,'Public transport operators with HIV Positive on ART','High risk population of Public transport operators with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public transport operators with HIV Positive on ART\n High risk population of Public transport operators with HIV Positive on ART\n \n 2023-03-29 21:37:07 UTC\n \n 2023-03-29 21:38: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 1953\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:37:07',4,'2023-03-29 23:38:05',4,0,NULL,NULL,NULL,'ebbb00b2-3779-47b8-8265-c8afea8a5ac1'),(1954,'Retreatment with HIV Positive on ART','High risk population of Retreatment Excl. Relapse HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment with HIV Positive on ART\n High risk population of Retreatment Excl. Relapse HIV Positive on ART\n \n 2023-03-29 21:39:16 UTC\n \n 2023-03-29 21:40: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 1954\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:39:16',4,'2023-03-29 23:40:08',4,0,NULL,NULL,NULL,'2ffdb12c-d02b-4e9a-a1dc-6e4974093b5a'),(1955,'Children < 15 with Positive HIV on CPT/Dapzone','Children < 15 with Positive HIV on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children < 15 with Positive HIV on CPT/Dapzone\n Children < 15 with Positive HIV on CPT/Dapzone\n \n 2023-03-29 21:44:42 UTC\n \n 2023-03-29 21:47: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 1955\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:44:42',4,'2023-03-29 23:47:53',4,0,NULL,NULL,NULL,'78313782-541c-4568-956c-9fb7bf92c08b'),(1956,'Correctional Staff and inmates with HIV Positive on CPT/Dapzone','High risk population of Correctional Staff and inmates with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Correctional Staff and inmates with HIV Positive on CPT/Dapzone\n High risk population of Correctional Staff and inmates with HIV Positive on CPT/Dapzone\n \n 2023-03-29 21:54:08 UTC\n \n 2023-03-29 21:56: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 1956\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:54:08',4,'2023-03-29 23:56:48',4,0,NULL,NULL,NULL,'46e76f2a-4fc0-40cf-be9d-61565edbe566'),(1957,'Ex Miner with HIV Positive on CPT/Dapzone','High risk population of Ex Miner with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex Miner with HIV Positive on CPT/Dapzone\n High risk population of Ex Miner with HIV Positive on CPT/Dapzone\n \n 2023-03-29 21:58:20 UTC\n \n 2023-03-29 21:59: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 1957\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:58:20',4,'2023-03-29 23:59:20',4,0,NULL,NULL,NULL,'348df991-95e1-4724-8df6-e4d905d67b11'),(1958,'Factory Workers with HIV Positive on CPT/Dapzone','High risk population of Factory Workers with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Workers with HIV Positive on CPT/Dapzone\n High risk population of Factory Workers with HIV Positive on CPT/Dapzone\n \n 2023-03-29 22:00:58 UTC\n \n 2023-03-29 22:02: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 1958\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 00:00:58',4,'2023-03-30 00:02:05',4,0,NULL,NULL,NULL,'5ce50877-ee92-48de-bfa7-a863b735975e'),(1959,'Health workers with HIV Positive on CPT/Dapzone','High risk population of Health workers with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health workers with HIV Positive on CPT/Dapzone\n High risk population of Health workers with HIV Positive on CPT/Dapzone\n \n 2023-03-29 22:03:33 UTC\n \n 2023-03-29 22:06: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 1959\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 00:03:33',4,'2023-03-30 00:06:16',4,0,NULL,NULL,NULL,'e47447de-6a64-422f-abe3-c281d2b4431c'),(1960,'HHCM with HIV Positive on CPT/Dapzone','High risk population of HHCM with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM with HIV Positive on CPT/Dapzone\n High risk population of HHCM with HIV Positive on CPT/Dapzone\n \n 2023-03-29 22:08:00 UTC\n \n 2023-03-29 22:09: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 1960\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 00:08:00',4,'2023-03-30 00:09:04',4,0,NULL,NULL,NULL,'02d9a185-dc0e-4852-8176-c4da69705d5d'),(1961,'HHXM with HIV Positive on CPT/Dapzone','High risk population of HHXM with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM with HIV Positive on CPT/Dapzone\n High risk population of HHXM with HIV Positive on CPT/Dapzone\n \n 2023-03-29 22:10:38 UTC\n \n 2023-03-29 22:11: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 1961\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 00:10:38',4,'2023-03-30 00:11:51',4,0,NULL,NULL,NULL,'c86cc664-d513-4afe-97b9-8163b4bb39d1'),(1962,'Miners with HIV Positive on CPT/Dapzone','High risk population Miners with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Miners with HIV Positive on CPT/Dapzone\n High risk population Miners with HIV Positive on CPT/Dapzone\n \n 2023-03-29 22:13:17 UTC\n \n 2023-03-29 22:15: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 1962\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 00:13:17',4,'2023-03-30 00:15:15',4,0,NULL,NULL,NULL,'7751e110-9e34-453e-bd9f-792272cbd895'),(1963,'New and Relapse with HIV Positive on CPT/Dapzone','High risk population of New and Relapse with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse with HIV Positive on CPT/Dapzone\n High risk population of New and Relapse with HIV Positive on CPT/Dapzone\n \n 2023-03-29 22:16:42 UTC\n \n 2023-03-29 22:18: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 1963\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 00:16:42',4,'2023-03-30 00:18:40',4,0,NULL,NULL,NULL,'2ebc8503-89e4-41f4-bdaf-e9e1d041a147'),(1964,'Public transport operators with HIV Positive on CPT/Dapzone','High risk population of Public transport operators with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public transport operators with HIV Positive on CPT/Dapzone\n High risk population of Public transport operators with HIV Positive on CPT/Dapzone\n \n 2023-03-30 08:39:11 UTC\n \n 2023-03-30 08:40: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 1964\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 10:39:11',4,'2023-03-30 10:40:29',4,0,NULL,NULL,NULL,'575068b5-f0ca-4d5b-8181-663b5feded65'),(1965,'Retreatment with HIV Positive on CPT/Dapzone','Retreatment Excl. Relapse with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment with HIV Positive on CPT/Dapzone\n Retreatment Excl. Relapse with HIV Positive on CPT/Dapzone\n \n 2023-03-30 08:41:45 UTC\n \n 2023-03-30 08:48: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 1965\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 10:41:45',4,'2023-03-30 10:48:08',4,0,NULL,NULL,NULL,'22dbd0dd-a4ca-42a5-986e-6c0012eb55b1'),(1966,'HHXM with Documented HIV Status','High risk population of HHXM with Documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM with Documented HIV Status\n High risk population of HHXM with Documented HIV Status\n \n 2023-03-30 09:03:54 UTC\n \n 2023-03-30 09:06: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 1966\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 11:03:54',4,'2023-03-30 11:06:14',4,0,NULL,NULL,NULL,'e5de47f6-aa7a-4b2d-bd72-83e5458977d6'),(1967,'TB Notification - Block 4','TB Notification - Block 4','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Notification - Block 4\n TB Notification - Block 4\n \n 2023-03-30 09:18:19 UTC\n \n 2023-03-30 20:54: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 1967\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-03-30 11:18:19',4,'2023-03-30 22:54:40',4,0,NULL,NULL,NULL,'0b9affca-ad93-42fb-bd49-57380f721a08'),(1968,'TBNotification - Block 4 Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TBNotification - Block 4 Data Set\n \n 2023-03-30 09:18:47 UTC\n \n 2023-03-30 20:50: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 1968\n \n \n DM_Sex\n \n \n \n \n \n \n \n \n ARTChild_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 ARTChild_M\n \n \n \n \n DM_Sex\n Males\n \n \n \n \n \n ARTCo&In_F\n \n \n \n \n \n \n \n \n \n ARTCo&In_M\n \n \n \n \n \n \n ARTFacW_F\n \n \n \n \n \n \n \n \n \n ARTFacW_M\n \n \n \n \n \n \n ARTHHCM_F\n \n \n \n \n \n \n \n \n \n ARTHHCM_M\n \n \n \n \n \n \n ARTHHXM_F\n \n \n \n \n \n \n \n \n \n ARTHHXM_M\n \n \n \n \n \n \n ARTHeaW_F\n \n \n \n \n \n \n \n \n \n ARTHeaW_M\n \n \n \n \n \n \n ARTMiner_F\n \n \n \n \n \n \n \n \n \n ARTMiner_M\n \n \n \n \n \n \n ARTNw&Rl_F\n \n \n \n \n \n \n \n \n \n ARTNw&Rl_M\n \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 ARTTrans_F\n \n \n \n \n \n \n \n \n \n ARTTrans_M\n \n \n \n \n \n \n ARTXMine_F\n \n \n \n \n \n \n \n \n \n ARTXMine_M\n \n \n \n \n \n \n DapChild_F\n \n \n \n \n \n \n \n \n \n DapChild_M\n \n \n \n \n \n \n DapCo&In_F\n \n \n \n \n \n \n \n \n \n DapCo&In_M\n \n \n \n \n \n \n DapFacW_F\n \n \n \n \n \n \n \n \n \n DapFacW_M\n \n \n \n \n \n \n DapHHCM_F\n \n \n \n \n \n \n \n \n \n DapHHCM_M\n \n \n \n \n \n \n DapHHXM_F\n \n \n \n \n \n \n \n \n \n DapHHXM_M\n \n \n \n \n \n \n DapHeaW_F\n \n \n \n \n \n \n \n \n \n DapHeaW_M\n \n \n \n \n \n \n DapMiner_F\n \n \n \n \n \n \n \n \n \n DapMiner_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 DapTrans_F\n \n \n \n \n \n \n \n \n \n DapTrans_M\n \n \n \n \n \n \n DapXMine_F\n \n \n \n \n \n \n \n \n \n DapXMine_M\n \n \n \n \n \n \n PosChild_F\n \n \n \n \n \n \n \n \n \n PosChild_M\n \n \n \n \n \n \n PosCo&In_F\n \n \n \n \n \n \n \n \n \n PosCo&In_M\n \n \n \n \n \n \n PosFacW_F\n \n \n \n \n \n \n \n \n \n PosFacW_M\n \n \n \n \n \n \n PosHHCM_F\n \n \n \n \n \n \n \n \n \n PosHHCM_M\n \n \n \n \n \n \n PosHHXM_F\n \n \n \n \n \n \n \n \n \n PosHHXM_M\n \n \n \n \n \n \n PosHeaW_F\n \n \n \n \n \n \n \n \n \n PosHeaW_M\n \n \n \n \n \n \n PosMiner_F\n \n \n \n \n \n \n \n \n \n PosMiner_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 PosTrans_F\n \n \n \n \n \n \n \n \n \n PosTrans_M\n \n \n \n \n \n \n PosXMine_F\n \n \n \n \n \n \n \n \n \n PosXMine_M\n \n \n \n \n \n \n StsChild_F\n \n \n \n \n \n \n \n \n \n StsChild_M\n \n \n \n \n \n \n StsCo&In_F\n \n \n \n \n \n \n \n \n \n StsCo&In_M\n \n \n \n \n \n \n StsFacW_F\n \n \n \n \n \n \n \n \n \n StsFacW_M\n \n \n \n \n \n \n StsHHCM_F\n \n \n \n \n \n \n \n \n \n StsHHCM_M\n \n \n \n \n \n \n StsHHXM_F\n \n \n \n \n \n \n \n \n \n StsHHXM_M\n \n \n \n \n \n \n StsHeaW_F\n \n \n \n \n \n \n \n \n \n StsHeaW_M\n \n \n \n \n \n \n StsMin_F\n \n \n \n \n \n \n \n \n \n StsMin_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 \n \n \n StsRetre_M\n \n \n \n \n \n \n StsTrans_F\n \n \n \n \n \n \n \n \n \n StsTrans_M\n \n \n \n \n \n \n StsXMin_F\n \n \n \n \n \n \n \n \n \n StsXMin_M\n \n \n \n \n \n \n','2023-03-30 11:18:47',4,'2023-03-30 22:50:08',4,0,NULL,NULL,NULL,'e08d273c-ba6d-4085-bf72-b7f6737396bf'),(1969,'TB_OUTCOMES','TB Outcomes','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB_OUTCOMES\n TB Outcomes\n \n 2023-03-30 13:48:45 UTC\n \n 2023-03-30 14:06: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 1969\n \n \n Competed\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-03-30 15:48:45',4,'2023-03-30 16:06:44',4,0,NULL,NULL,NULL,'2244b6f7-5dd0-4c8a-8a9e-67bac3fe7d9b'),(1970,'test','test','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n test\n test\n \n 2023-03-30 14:06:01 UTC\n \n \n','2023-03-30 16:06:01',4,NULL,NULL,0,NULL,NULL,NULL,'a572d104-f644-42bb-ae58-7c83ac0747ad'),(1971,'TB New and Relapse Completed','TB New and Relapse Completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Completed\n TB New and Relapse Completed\n \n 2023-03-30 14:58:43 UTC\n \n 2023-03-30 14: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 1971\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 -- TB History of previous treatment \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 (1034,1084) \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 and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 16:58:43',4,'2023-03-30 16:59:47',4,0,NULL,NULL,NULL,'1540870d-551a-4e11-baad-70ed9b13289a'),(1972,'TB New and Relapse Cured','TB New and Relapse Cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Cured\n TB New and Relapse Cured\n \n 2023-03-30 15:04:42 UTC\n \n 2023-03-30 15:06: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 1972\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 -- TB History of previous treatment(New AND 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 (1034,1084) \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-03-30 17:04:42',4,'2023-03-30 17:06:17',4,0,NULL,NULL,NULL,'22e1906b-16cd-4109-b529-a043e43ff3d4'),(1973,'TB New and Relapse Died','TB New and Relapse Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Died\n TB New and Relapse Died\n \n 2023-03-30 15:08:32 UTC\n \n 2023-03-30 15:09: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 1973\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 -- TB History of previous treatment(New AND 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 (1034,1084) \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-03-30 17:08:32',4,'2023-03-30 17:09:15',4,0,NULL,NULL,NULL,'19636929-afd0-4ba0-acfa-bbe325e1f002'),(1974,'TB New and Relapse Lost to Follow-up','TB New and Relapse 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 TB New and Relapse Lost to Follow-up\n TB New and Relapse Lost to Follow-up\n \n 2023-03-30 15:10:23 UTC\n \n 2023-03-30 15:10: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 1974\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 -- TB History of previous treatment(New AND 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 (1034,1084) \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-03-30 17:10:23',4,'2023-03-30 17:10:58',4,0,NULL,NULL,NULL,'87260731-779f-4244-9480-f75169dd2fbf'),(1975,'TB New and Relapse Failed (Susceptible)','TB New and Relapse Failed (Susceptible)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Failed (Susceptible)\n TB New and Relapse Failed (Susceptible)\n \n 2023-03-30 15:11:55 UTC\n \n 2023-03-30 15:31: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 1975\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 -- TB History of previous treatment(New AND 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 (1034,1084) \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-03-30 17:11:55',4,'2023-03-30 17:31:39',4,0,NULL,NULL,NULL,'53aec520-fab0-4871-b46f-209c32b921c1'),(1976,'TB New and Relapse Not Evaluated','TB New and Relapse Not Evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Not Evaluated\n TB New and Relapse Not Evaluated\n \n 2023-03-30 15:13:29 UTC\n \n 2023-03-30 16:05: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 1976\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 -- TB History of previous treatment(New AND 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 (1034,1084) \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,2242,3650,2302,3793,3794) \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 17:13:29',4,'2023-03-30 18:05:12',4,0,NULL,NULL,NULL,'0af163fd-0d3c-4b6a-a84e-1648cd9bb042'),(1977,'exMiner_cured','Ex miner cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n exMiner_cured\n Ex miner cured\n \n 2023-03-30 15:21:40 UTC\n \n 2023-03-30 15:47: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 1977\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 = 3668 \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 = 1068 \n and b.voided = 0 \n ) \n\n','2023-03-30 17:21:40',4,'2023-03-30 17:47:23',4,0,NULL,NULL,NULL,'4c2c88ec-ee4e-4bad-962d-229983982f12'),(1978,'exMiner_completed','Ex miner completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n exMiner_completed\n Ex miner completed\n \n 2023-03-30 15:24:54 UTC\n \n 2023-03-30 15:45: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 1978\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 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 = 3668 \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 = 2242 \n and b.voided = 0 \n ) \n\n','2023-03-30 17:24:54',4,'2023-03-30 17:45:56',4,0,NULL,NULL,NULL,'37afe774-0ef1-4152-8ab9-fe702f175f36'),(1979,'exMiner_died','Ex Miner died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n exMiner_died\n Ex Miner died\n \n 2023-03-30 15:28:17 UTC\n \n 2023-04-03 07:35: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 1979\n select distinct o.person_id \n \n \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 = 3668 \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 = 3650 and b.voided = 0 \n ) \n\n','2023-03-30 17:28:17',4,'2023-04-03 09:35:05',4,0,NULL,NULL,NULL,'d08b3fb0-d1c2-455d-89a6-f3c9a1469a3e'),(1980,'TB New and Relapse Completed Moved to second line treatment','TB New and Relapse Completed Moved to second line treatment','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Completed Moved to second line treatment\n TB New and Relapse Completed Moved to second line treatment\n \n 2023-03-30 15:33:00 UTC\n \n 2023-03-30 15:33: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 1980\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 -- TB History of previous treatment(New AND 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 (1034,1084) \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-03-30 17:33:00',4,'2023-03-30 17:33:47',4,0,NULL,NULL,NULL,'d2ff18e1-1cf3-4bff-9796-e35aaf019b40'),(1981,'exMiner_failedSusceptive','Ex miner failed suceptive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n exMiner_failedSusceptive\n Ex miner failed suceptive\n \n 2023-03-30 15:40:13 UTC\n \n 2023-04-03 10:56: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 1981\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 = 3668 \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 = 3793 \n and b.voided = 0 \n ) \n\n','2023-03-30 17:40:13',4,'2023-04-03 12:56:48',4,0,NULL,NULL,NULL,'8c7c6720-c1aa-492a-be1b-47edc57cfd55'),(1982,'exMiner_lost','Ex miner lost','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n exMiner_lost\n Ex miner lost\n \n 2023-03-30 15:42:32 UTC\n \n 2023-03-30 15:49: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 1982\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 = 3668 \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 = 2302 \n and b.voided = 0 \n ) \n\n','2023-03-30 17:42:32',4,'2023-03-30 17:49:29',4,0,NULL,NULL,NULL,'cb57dd5b-22ae-42d9-a86a-6927e9aae9cb'),(1983,'TB Retreatment excluding Relapse and Completed','TB Retreatment excluding Relapse and Completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Retreatment excluding Relapse and Completed\n TB Retreatment excluding Relapse and Completed\n \n 2023-03-30 15:43:38 UTC\n \n 2023-03-30 15:44: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 1983\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 -- TB History of previous treatment(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 = 2242 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 17:43:38',4,'2023-03-30 17:44:32',4,0,NULL,NULL,NULL,'93eefc43-0eba-4a27-8d7e-72958dc0b2f1'),(1984,'exMiner_movedSecondLIne','Ex miner moved to second line','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n exMiner_movedSecondLIne\n Ex miner moved to second line\n \n 2023-03-30 15:44:13 UTC\n \n 2023-03-30 15:44: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 1984\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 = 3668 \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 = 3794 \n and b.voided = 0 \n ) \n\n','2023-03-30 17:44:13',4,'2023-03-30 17:44:34',4,0,NULL,NULL,NULL,'846e0252-747b-4457-b0f4-6f23ed244706'),(1985,'TB Retreatment excluding Relapse and Cured','TB Retreatment excluding Relapse and Cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Retreatment excluding Relapse and Cured\n TB Retreatment excluding Relapse and Cured\n \n 2023-03-30 15:45:00 UTC\n \n 2023-03-30 15:45: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 1985\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 -- TB History of previous treatment(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 = 1068 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 17:45:00',4,'2023-03-30 17:45:29',4,0,NULL,NULL,NULL,'1cd8596a-21ba-4a7b-b3c6-c82fb756bf8f'),(1986,'TB Retreatment excluding Relapse and Died','TB Retreatment excluding Relapse and Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Retreatment excluding Relapse and Died\n TB Retreatment excluding Relapse and Died\n \n 2023-03-30 15:45:57 UTC\n \n 2023-03-30 15:46: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 1986\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 -- TB History of previous treatment(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 = 3650 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 17:45:57',4,'2023-03-30 17:46:22',4,0,NULL,NULL,NULL,'50001a13-545a-4de2-9617-86c8b262eb9d'),(1987,'TB Retreatment excluding Relapse and Lost to Follow up','TB Retreatment excluding Relapse and 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 TB Retreatment excluding Relapse and Lost to Follow up\n TB Retreatment excluding Relapse and Lost to Follow up\n \n 2023-03-30 15:47:18 UTC\n \n 2023-03-30 15:47: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 1987\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 -- TB History of previous treatment(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 = 2302 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 17:47:18',4,'2023-03-30 17:47:57',4,0,NULL,NULL,NULL,'46fbbe80-0f0e-4cf5-8f4d-04444b70d3bc'),(1988,'TB Retreatment excluding Relapse and Failed (Susceptible)','TB Retreatment excluding Relapse and Failed (Susceptible)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Retreatment excluding Relapse and Failed (Susceptible)\n TB Retreatment excluding Relapse and Failed (Susceptible)\n \n 2023-03-30 15:49:14 UTC\n \n 2023-03-30 15:49: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 1988\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 -- TB History of previous treatment(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 = 3793 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 17:49:14',4,'2023-03-30 17:49:46',4,0,NULL,NULL,NULL,'0b97c9a2-f4f0-460c-9a6a-943f0d0b9bac'),(1989,'TB Retreatment excluding Relapse and Not Evaluated','TB Retreatment excluding Relapse and Not Evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Retreatment excluding Relapse and Not Evaluated\n TB Retreatment excluding Relapse and Not Evaluated\n \n 2023-03-30 15:51:27 UTC\n \n 2023-03-30 16: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 1989\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 -- TB History of previous treatment(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 not in ( \n select o.person_id \n from obs o \n where o.concept_id = 3792 and o.value_coded in (1068,2242,3650,2302,3793,3794) \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 17:51:27',4,'2023-03-30 18:03:56',4,0,NULL,NULL,NULL,'36e8a6f3-f70c-4d36-ab76-87fba12b426b'),(1990,'exMiner_notEvaluated','Ex miner not evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n exMiner_notEvaluated\n Ex miner not evaluated\n \n 2023-03-30 15:53:42 UTC\n \n 2023-03-30 16:13: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 1990\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 = 3668 \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-03-30 17:53:42',4,'2023-03-30 18:13:01',4,0,NULL,NULL,NULL,'af666d60-a3d1-4f0f-8ac2-1ea8fddbf8cd'),(1991,'FactoryWorker_notEvaluated','Factory worker not evaluated ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n FactoryWorker_notEvaluated\n Factory worker not evaluated \n \n 2023-03-30 16:17:17 UTC\n \n 2023-03-30 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 1991\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 = 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 (2302,1068,2242,3650,3793,3794) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:17:17',4,'2023-03-30 18:18:05',4,0,NULL,NULL,NULL,'83566c8a-550c-447e-9745-0df04c89de07'),(1992,'FactoryWorker_curred','Factory worker curred','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n FactoryWorker_curred\n Factory worker curred\n \n 2023-03-30 16:18:46 UTC\n \n 2023-03-30 16: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 1992\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 (1068) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:18:46',4,'2023-03-30 18:19:13',4,0,NULL,NULL,NULL,'40dd9f46-8d30-4426-bffd-0eb772046374'),(1993,'All TB HIV Pos and Completed ','All TB HIV Pos and Completed ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Pos and Completed \n All TB HIV Pos and Completed \n \n 2023-03-30 16:19:51 UTC\n \n 2023-03-30 16:20: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 1993\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 -- All HIV Positives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4323,4664) \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-03-30 18:19:51',4,'2023-03-30 18:20:08',4,0,NULL,NULL,NULL,'6b7c8fdf-00e6-4f52-b0fe-fab2cd9cc15e'),(1994,'FactoryWorker_completed','Factory worker copleted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n FactoryWorker_completed\n Factory worker copleted\n \n 2023-03-30 16:19:51 UTC\n \n 2023-03-30 16:20: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 1994\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 = 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 (2242) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:19:51',4,'2023-03-30 18:20:13',4,0,NULL,NULL,NULL,'4fb972d7-5378-4413-8faf-e9dfc9454cd6'),(1995,'All TB HIV Pos and Cured','All TB HIV Pos and Cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Pos and Cured\n All TB HIV Pos and Cured\n \n 2023-03-30 16:20:26 UTC\n \n 2023-03-30 16:20: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 1995\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 -- All HIV Positives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4323,4664) \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-03-30 18:20:26',4,'2023-03-30 18:20:55',4,0,NULL,NULL,NULL,'5bd61f52-4224-4de9-82cd-2c6334f665b1'),(1996,'FactoryWorker_died','Factory worker died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n FactoryWorker_died\n Factory worker died\n \n 2023-03-30 16:21:09 UTC\n \n 2023-03-30 16:21: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 1996\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 = 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 (3650) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:21:09',4,'2023-03-30 18:21:24',4,0,NULL,NULL,NULL,'f4cf99eb-4bb4-45c0-a403-086fd4b51c44'),(1997,'All TB HIV Pos and Died','All TB HIV Pos and Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Pos and Died\n All TB HIV Pos and Died\n \n 2023-03-30 16:21:20 UTC\n \n 2023-03-30 16:21: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 1997\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 -- All HIV Positives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4323,4664) \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-03-30 18:21:20',4,'2023-03-30 18:21:50',4,0,NULL,NULL,NULL,'b41362c1-57e7-48a0-99ed-a6241cd9fb3d'),(1998,'FactoryWorker_lost','Factort worker 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 FactoryWorker_lost\n Factort worker lost to follow up\n \n 2023-03-30 16:22:18 UTC\n \n 2023-03-30 16:22: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 1998\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 = 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 (2302) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:22:18',4,'2023-03-30 18:22:39',4,0,NULL,NULL,NULL,'f915f74e-1e06-4639-9070-6d1fa301b432'),(1999,'All TB HIV Pos and Lost to Follow up','All TB HIV Pos and 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 All TB HIV Pos and Lost to Follow up\n All TB HIV Pos and Lost to Follow up\n \n 2023-03-30 16:22:31 UTC\n \n 2023-03-30 16:22: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 1999\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 -- All HIV Positives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4323,4664) \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-03-30 18:22:31',4,'2023-03-30 18:22:58',4,0,NULL,NULL,NULL,'16efd94d-da75-4a5c-8ca9-6364f2fc8396'),(2000,'All TB HIV Pos and Failed (Susceptible)','All TB HIV Pos and Failed (Susceptible)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Pos and Failed (Susceptible)\n All TB HIV Pos and Failed (Susceptible)\n \n 2023-03-30 16:23:33 UTC\n \n 2023-03-30 16:24: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 2000\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 -- All HIV Positives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4323,4664) \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-03-30 18:23:33',4,'2023-03-30 18:24:00',4,0,NULL,NULL,NULL,'4dc42500-c285-4548-92ff-842d1b357342'),(2001,'prison_worker_lost','Prison worker lost','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n prison_worker_lost\n Prison worker lost\n \n 2023-03-30 16:24:03 UTC\n \n 2023-03-30 16:24: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 2001\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 = 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 (2302) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:24:03',4,'2023-03-30 18:24:36',4,0,NULL,NULL,NULL,'624478ae-cc98-4b93-b138-4e619755b41a'),(2002,'All TB HIV Pos and Not Evaluated','All TB HIV Pos and Not Evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Pos and Not Evaluated\n All TB HIV Pos and Not Evaluated\n \n 2023-03-30 16:24:48 UTC\n \n 2023-03-30 16:26: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 2002\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 -- All HIV Positives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4323,4664) \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,2242,3650,2302,3793,3794) \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 18:24:48',4,'2023-03-30 18:26:26',4,0,NULL,NULL,NULL,'4fe00951-413a-468e-ac7e-016dcf41bed6'),(2003,'FactoryWorker_moved','Facotory worker moved to second line','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n FactoryWorker_moved\n Facotory worker moved to second line\n \n 2023-03-30 16:26:31 UTC\n \n 2023-03-30 16:34: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 2003\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 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-03-30 18:26:31',4,'2023-03-30 18:34:39',4,0,NULL,NULL,NULL,'1a7a972b-4113-414d-8810-46c8df8137e7'),(2004,'All TB HIV Pos and Moved to Secondline','All TB HIV Pos and Moved to Secondline','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Pos and Moved to Secondline\n All TB HIV Pos and Moved to Secondline\n \n 2023-03-30 16:27:16 UTC\n \n 2023-03-30 16:27: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 2004\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 -- All HIV Positives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4323,4664) \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-03-30 18:27:16',4,'2023-03-30 18:27:43',4,0,NULL,NULL,NULL,'57ddf49d-b53d-48ce-a67d-3ce6398f3e2c'),(2005,'All TB HIV Neg and Completed','All TB HIV Neg and Completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Neg and Completed\n All TB HIV Neg and Completed\n \n 2023-03-30 16:29:02 UTC\n \n 2023-03-30 16:30: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 2005\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 -- All HIV Negatives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4324,4665) \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-03-30 18:29:02',4,'2023-03-30 18:30:27',4,0,NULL,NULL,NULL,'63a92814-2f34-4018-b7d0-47659892369d'),(2006,'All TB HIV Neg and Cured','All TB HIV Neg and Cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Neg and Cured\n All TB HIV Neg and Cured\n \n 2023-03-30 16:30:51 UTC\n \n 2023-03-30 16:31: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 2006\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 -- All HIV Negatives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4324,4665) \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-03-30 18:30:51',4,'2023-03-30 18:31:17',4,0,NULL,NULL,NULL,'8e552272-4654-43bb-b1af-20affab2de14'),(2007,'All TB HIV Neg and Died','All TB HIV Neg and Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Neg and Died\n All TB HIV Neg and Died\n \n 2023-03-30 16:31:44 UTC\n \n 2023-03-30 16:32: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 2007\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 -- All HIV Negatives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4324,4665) \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-03-30 18:31:44',4,'2023-03-30 18:32:11',4,0,NULL,NULL,NULL,'3463adc8-19aa-4cc0-9daf-32ea09e0c1f0'),(2008,'All TB HIV Neg and Lost to Follow up','All TB HIV Neg and 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 All TB HIV Neg and Lost to Follow up\n All TB HIV Neg and Lost to Follow up\n \n 2023-03-30 16:32:59 UTC\n \n 2023-03-30 16: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 2008\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 -- All HIV Negatives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4324,4665) \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-03-30 18:32:59',4,'2023-03-30 18:33:27',4,0,NULL,NULL,NULL,'06a5ff53-1949-444e-80b5-f4c99b38d5b1'),(2009,'All TB HIV Neg and Failed (Susceptible)','All TB HIV Neg and Failed (Susceptible)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Neg and Failed (Susceptible)\n All TB HIV Neg and Failed (Susceptible)\n \n 2023-03-30 16:34:17 UTC\n \n 2023-03-30 16:35: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 2009\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 -- All HIV Negatives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4324,4665) \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-03-30 18:34:17',4,'2023-03-30 18:35:01',4,0,NULL,NULL,NULL,'2ac7e18e-061b-4b34-bb63-63a2ec622a2b'),(2010,'All TB HIV Neg and Not Evaluated','All TB HIV Neg and Not Evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Neg and Not Evaluated\n All TB HIV Neg and Not Evaluated\n \n 2023-03-30 16:35:36 UTC\n \n 2023-03-30 16:37: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 2010\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 -- All HIV Negatives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4324,4665) \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,2242,3650,2302,3793,3794) \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 18:35:36',4,'2023-03-30 18:37:02',4,0,NULL,NULL,NULL,'c78c5a10-a320-43ce-b943-f9286e22ad1e'),(2011,'prison_worker_moved','Prison worker moved to second line','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n prison_worker_moved\n Prison worker moved to second line\n \n 2023-03-30 16:35:49 UTC\n \n 2023-03-30 16:36: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 2011\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 = 3779 \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-03-30 18:35:49',4,'2023-03-30 18:36:29',4,0,NULL,NULL,NULL,'76d5be40-a7e3-4f4f-968a-0346d0bd6513'),(2012,'prison_worker_died','Prison worker died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n prison_worker_died\n Prison worker died\n \n 2023-03-30 16:37:07 UTC\n \n 2023-03-30 16:37: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 2012\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 = 3776 \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-03-30 18:37:07',4,'2023-03-30 18:37:38',4,0,NULL,NULL,NULL,'c9a54e7c-34d1-4a1b-9214-0b9fa6eb6976'),(2013,'All TB HIV Neg and Moved to Secondline Treatment','All TB HIV Neg and 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 All TB HIV Neg and Moved to Secondline Treatment\n All TB HIV Neg and Moved to Secondline Treatment\n \n 2023-03-30 16:37:41 UTC\n \n 2023-03-30 16:38: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 2013\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 -- All HIV Negatives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4324,4665) \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-03-30 18:37:41',4,'2023-03-30 18:38:53',4,0,NULL,NULL,NULL,'2de9ce1c-6a79-43fe-ab19-1b9c9d2865d4'),(2014,'prison_worker_completed','Prison worker completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n prison_worker_completed\n Prison worker completed\n \n 2023-03-30 16:38:29 UTC\n \n 2023-03-30 16:38: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 2014\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 = 3776 \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-03-30 18:38:29',4,'2023-03-30 18:38:53',4,0,NULL,NULL,NULL,'9e174142-2794-43fc-95dd-9f3f92e4b379'),(2015,'prison_worker_curred','Prion worker curred','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n prison_worker_curred\n Prion worker curred\n \n 2023-03-30 16:40:22 UTC\n \n 2023-03-30 16: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 2015\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 = 3776 \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-03-30 18:40:22',4,'2023-03-30 18:43:23',4,0,NULL,NULL,NULL,'91f85b53-7dca-4730-a391-5198293d1cf9'),(2016,'All Childred and Completed','All Childred and Completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All Childred and Completed\n All Childred and Completed\n \n 2023-03-30 16:43:19 UTC\n \n 2023-03-30 16:46: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 2016\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 -- All Children \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 15 \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-03-30 18:43:19',4,'2023-03-30 18:46:26',4,0,NULL,NULL,NULL,'f300ef4e-70b5-4c81-b993-7d45d23f299e'),(2017,'prison_worker_notEvaluated','Prison worker not evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n prison_worker_notEvaluated\n Prison worker not evaluated\n \n 2023-03-30 16:46:21 UTC\n \n 2023-03-30 16:46: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 2017\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 = 3776 \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-03-30 18:46:21',4,'2023-03-30 18:46:41',4,0,NULL,NULL,NULL,'1c0c7eab-e438-4787-982a-bfb448fe7455'),(2018,'All Childred and Cured','All Childred and Cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All Childred and Cured\n All Childred and Cured\n \n 2023-03-30 16:46:51 UTC\n \n 2023-03-30 16:47: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 2018\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 -- All Children \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 15 \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-03-30 18:46:51',4,'2023-03-30 18:47:08',4,0,NULL,NULL,NULL,'1f8f36b9-85d6-4e32-b078-6c7e098974b1'),(2019,'All Childred and Died','All Childred and Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All Childred and Died\n All Childred and Died\n \n 2023-03-30 16:47:31 UTC\n \n 2023-03-30 16:48: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 2019\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 -- All Children \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 15 \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-03-30 18:47:31',4,'2023-03-30 18:48:00',4,0,NULL,NULL,NULL,'dd4822a7-86eb-4579-acda-bf0ff242eef5'),(2020,'health_worker_notEvaluated','Health worker not evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n health_worker_notEvaluated\n Health worker not evaluated\n \n 2023-03-30 16:47:35 UTC\n \n 2023-03-30 16:48: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 2020\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 = 3667 \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-03-30 18:47:35',4,'2023-03-30 18:48:03',4,0,NULL,NULL,NULL,'5d8bdedf-fc1e-46f8-b417-908519f3e645'),(2021,'All Childred and Lost to Follow up','All Childred and 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 All Childred and Lost to Follow up\n All Childred and Lost to Follow up\n \n 2023-03-30 16:48:38 UTC\n \n 2023-03-30 16:49: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 2021\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 -- All Children \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 15 \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-03-30 18:48:38',4,'2023-03-30 18:49:04',4,0,NULL,NULL,NULL,'2665ef1b-edbd-4c9d-b9f6-3d2d2cc3b0ad'),(2022,'health_worker_curred','Health worker curred','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n health_worker_curred\n Health worker curred\n \n 2023-03-30 16:48:53 UTC\n \n 2023-03-30 16:49: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 2022\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 = 3667 \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-03-30 18:48:53',4,'2023-03-30 18:49:19',4,0,NULL,NULL,NULL,'63064b04-2cce-4944-b53d-ddb2cdce8a2d'),(2023,'All Childred and Failed (Susceptible)','All Childred and Failed (Susceptible)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All Childred and Failed (Susceptible)\n All Childred and Failed (Susceptible)\n \n 2023-03-30 16:49:34 UTC\n \n 2023-03-30 16:50: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 2023\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 -- All Children \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 15 \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-03-30 18:49:34',4,'2023-03-30 18:50:01',4,0,NULL,NULL,NULL,'1b710ad4-75b5-4b64-b916-1806dca0013d'),(2024,'health_worker_completed','Health worker completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n health_worker_completed\n Health worker completed\n \n 2023-03-30 16:49:56 UTC\n \n 2023-04-03 20:37: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 2024\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 = 3667 \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-03-30 18:49:56',4,'2023-04-03 22:37:45',4,0,NULL,NULL,NULL,'6555808c-1103-4a6d-b13f-fd0fad7ff09f'),(2025,'All Childred and Not evaluated','All Childred and Not evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All Childred and Not evaluated\n All Childred and Not evaluated\n \n 2023-03-30 16:50:30 UTC\n \n 2023-03-30 16:51: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 2025\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 -- All Children \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 15 \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,2242,3650,2302,3794,3793) \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 18:50:30',4,'2023-03-30 18:51:54',4,0,NULL,NULL,NULL,'1b9b16cf-f254-43b5-b952-4d54f431ae49'),(2026,'health_worker_died','Healh worker died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n health_worker_died\n Healh worker died\n \n 2023-03-30 16:50:46 UTC\n \n 2023-03-30 16:51: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 2026\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 = 3667 \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-03-30 18:50:46',4,'2023-03-30 18:51:00',4,0,NULL,NULL,NULL,'e9c9f85f-123c-4b2f-9951-7b8c2be340af'),(2027,'health_worker_lost','Health worker lost','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n health_worker_lost\n Health worker lost\n \n 2023-03-30 16:51:39 UTC\n \n 2023-03-30 16:51: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 2027\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 = 3667 \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-03-30 18:51:39',4,'2023-03-30 18:51:55',4,0,NULL,NULL,NULL,'8b70ced1-8219-4206-b7ec-10c0242808c4'),(2028,'All Childred and Moved to Secondline Treatment','All Childred and 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 All Childred and Moved to Secondline Treatment\n All Childred and Moved to Secondline Treatment\n \n 2023-03-30 16:52:27 UTC\n \n 2023-03-30 16:53: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 2028\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 -- All Children \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 15 \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-03-30 18:52:27',4,'2023-03-30 18:53:11',4,0,NULL,NULL,NULL,'143c95e1-ae28-460c-92c2-3807e30dc704'),(2029,'health_worker_moved','Health worker moved to second line','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n health_worker_moved\n Health worker moved to second line\n \n 2023-03-30 16:52:49 UTC\n \n 2023-03-30 16:55: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 2029\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 = 3667 \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-03-30 18:52:49',4,'2023-03-30 18:55:13',4,0,NULL,NULL,NULL,'3a04d202-b320-463e-a233-40887022bfea'),(2030,'All TB Adolescent (10-19 yrs) and Completed ','All TB Adolescent (10-19 yrs) and Completed ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','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-03-30 16:55:50 UTC\n \n 2023-03-30 16: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 2030\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 -- All Adolescent (10-19 yrs) \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 20 \n and floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) > 9 \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-03-30 18:55:50',4,'2023-03-30 18:56:27',4,0,NULL,NULL,NULL,'788061f8-b372-4d67-b493-c20b96b948bf'),(2031,'public_transport_Moved','Public Transport move to second line','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n public_transport_Moved\n Public Transport move to second line\n \n 2023-03-30 16:55:50 UTC\n \n 2023-03-30 16:56: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 2031\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 = 4654 \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-03-30 18:55:50',4,'2023-03-30 18:56:22',4,0,NULL,NULL,NULL,'c2e7a54e-80e6-4535-a09f-32d93e8ce902'),(2032,'All TB Adolescent (10-19 yrs) and cured','All TB Adolescent (10-19 yrs) and cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','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-03-30 16:56:54 UTC\n \n 2023-03-30 16:57: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 2032\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 -- All Adolescent (10-19 yrs) \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 20 \n and floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) > 9 \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-03-30 18:56:54',4,'2023-03-30 18:57:31',4,0,NULL,NULL,NULL,'e620cd1b-bbe2-4c3d-93bb-fcbdc8b34d84'),(2033,'public_transport_lost','Public transport Lost','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n public_transport_lost\n Public transport Lost\n \n 2023-03-30 16:57:13 UTC\n \n 2023-03-30 16:57: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 2033\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 = 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 (2302) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:57:13',4,'2023-03-30 18:57:37',4,0,NULL,NULL,NULL,'0cc2e2d8-4cab-45c7-9b04-67c8bfd1bbfa'),(2034,'All TB Adolescent (10-19 yrs) and Died','All TB Adolescent (10-19 yrs) and Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','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-03-30 16:57:52 UTC\n \n 2023-03-30 16:58: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 2034\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 -- All Adolescent (10-19 yrs) \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 20 \n and floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) > 9 \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-03-30 18:57:52',4,'2023-03-30 18:58:21',4,0,NULL,NULL,NULL,'53ef1628-fe11-4b21-bab5-897e27196e04'),(2035,'public_transport_died','Public transport died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n public_transport_died\n Public transport died\n \n 2023-03-30 16:58:17 UTC\n \n 2023-03-30 16:58: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 2035\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 = 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 (3650) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:58:17',4,'2023-03-30 18:58:34',4,0,NULL,NULL,NULL,'bbc25dd6-f8ff-4c55-84e8-efd76d0ac281'),(2036,'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.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','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-03-30 16:58:49 UTC\n \n 2023-03-30 16: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 2036\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 -- All Adolescent (10-19 yrs) \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 20 \n and floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) > 9 \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-03-30 18:58:49',4,'2023-03-30 18:59:12',4,0,NULL,NULL,NULL,'509944d6-5988-405c-8aee-8a9329e1e141'),(2037,'public_transport_completed','Public transport completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n public_transport_completed\n Public transport completed\n \n 2023-03-30 16:59:27 UTC\n \n 2023-03-30 17:00: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 2037\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 (2242) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:59:27',4,'2023-03-30 19:00:28',4,0,NULL,NULL,NULL,'d9a7884a-eabd-43cc-9757-64ae74a3cb9c'),(2038,'All TB Adolescent (10-19 yrs) and Failed (Susceptible)','All TB Adolescent (10-19 yrs) and Failed (Susceptible)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB Adolescent (10-19 yrs) and Failed (Susceptible)\n All TB Adolescent (10-19 yrs) and Failed (Susceptible)\n \n 2023-03-30 16:59:52 UTC\n \n 2023-03-30 17:00: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 2038\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 -- All Adolescent (10-19 yrs) \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 20 \n and floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) > 9 \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-03-30 18:59:52',4,'2023-03-30 19:00:27',4,0,NULL,NULL,NULL,'dd3ac915-529a-44c4-b086-fe9e21bc7553'),(2039,'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.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','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-03-30 17:01:19 UTC\n \n 2023-03-30 17:01: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 2039\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 -- All Adolescent (10-19 yrs) \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 20 \n and floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) > 9 \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-03-30 19:01:19',4,'2023-03-30 19:01:41',4,0,NULL,NULL,NULL,'216e1e3c-eed7-4802-96bb-fe3256161a08'),(2040,'public_transport_curred','Public transport curred','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n public_transport_curred\n Public transport curred\n \n 2023-03-30 17:01:20 UTC\n \n 2023-03-30 17:01: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 2040\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 = 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 (1068) \n and b.voided = 0 \n ) \n\n','2023-03-30 19:01:20',4,'2023-03-30 19:01:41',4,0,NULL,NULL,NULL,'faf660cd-1ef3-48a9-86d5-805f14b23465'),(2041,'All TB Adolescent (10-19 yrs) and Not Evaluated','All TB Adolescent (10-19 yrs) and Not Evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','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-03-30 17:02:10 UTC\n \n 2023-03-30 17:03: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 2041\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 -- All Adolescent (10-19 yrs) \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 20 \n and floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) > 9 \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,2242,3650,2302,3794,3793) \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 19:02:10',4,'2023-03-30 19:03:44',4,0,NULL,NULL,NULL,'8fcd3cec-a879-4240-888f-42575228b47d'); -INSERT INTO `serialized_object` VALUES (2042,'public_transport_notEvaluated','Public transport note evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n public_transport_notEvaluated\n Public transport note evaluated\n \n 2023-03-30 17:02:53 UTC\n \n 2023-03-30 17:03: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 2042\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 (2302,1068,2242,3650,3793,3794) \n and b.voided = 0 \n ) \n\n','2023-03-30 19:02:53',4,'2023-03-30 19:03:45',4,0,NULL,NULL,NULL,'7037beac-7eba-4b7f-a3b7-6636d1d435bd'),(2043,'TB Females and Completed','TB Females and Completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Females and Completed\n TB Females and Completed\n \n 2023-03-30 17:07:55 UTC\n \n 2023-03-30 17:08: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 2043\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 -- Female \n and o.person_id in ( \n select o.person_id \n from obs o \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 where person.gender = 'F' \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-03-30 19:07:55',4,'2023-03-30 19:08:14',4,0,NULL,NULL,NULL,'82abec75-7c2a-4607-b3b1-b3ef5c6c4361'),(2044,'TB Females and Cured','TB Females and Cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Females and Cured\n TB Females and Cured\n \n 2023-03-30 17:08:50 UTC\n \n 2023-03-30 17:09: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 2044\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 -- Female \n and o.person_id in ( \n select o.person_id \n from obs o \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 where person.gender = 'F' \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-03-30 19:08:50',4,'2023-03-30 19:09:12',4,0,NULL,NULL,NULL,'f746ec4b-a949-4b53-86c8-4e1a71843d72'),(2045,'HHCM_notEvaluated','HHCM Note Evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM_notEvaluated\n HHCM Note Evaluated\n \n 2023-03-30 17:09:07 UTC\n \n 2023-03-30 17:09: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 2045\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 = 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 (2302,1068,2242,3650,3793,3794) \n and b.voided = 0 \n ) \n\n','2023-03-30 19:09:07',4,'2023-03-30 19:09:44',4,0,NULL,NULL,NULL,'d8caa7dd-326a-46f7-97ee-f7205689bfda'),(2046,'HHCM_curred','HHCM Curred','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM_curred\n HHCM Curred\n \n 2023-03-30 17:10:16 UTC\n \n 2023-03-30 17:10: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 2046\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 = 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 (1068) \n and b.voided = 0 \n ) \n\n','2023-03-30 19:10:16',4,'2023-03-30 19:10:39',4,0,NULL,NULL,NULL,'ea1cc81f-9ccc-4401-80e9-57a84da98f58'),(2047,'TB Females and Died','TB Females and Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Females and Died\n TB Females and Died\n \n 2023-03-30 17:11:17 UTC\n \n 2023-03-30 17:11: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 2047\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 -- Female \n and o.person_id in ( \n select o.person_id \n from obs o \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 where person.gender = 'F' \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-03-30 19:11:17',4,'2023-03-30 19:11:45',4,0,NULL,NULL,NULL,'f55690e5-8b8d-43ce-b797-f0f8707d1222'),(2048,'HHCM_completed','HHCM Completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM_completed\n HHCM Completed\n \n 2023-03-30 17:12:02 UTC\n \n 2023-03-30 17:12: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 2048\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 = 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 (2242) \n and b.voided = 0 \n ) \n\n','2023-03-30 19:12:02',4,'2023-03-30 19:12:21',4,0,NULL,NULL,NULL,'7dbf3689-913d-4883-ae4b-5be2aee4ba37'),(2049,'TB Females and Lost to Follow up','TB Females and 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 TB Females and Lost to Follow up\n TB Females and Lost to Follow up\n \n 2023-03-30 17:12:17 UTC\n \n 2023-03-30 17:13: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 2049\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 -- Female \n and o.person_id in ( \n select o.person_id \n from obs o \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 where person.gender = 'F' \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-03-30 19:12:17',4,'2023-03-30 19:13:14',4,0,NULL,NULL,NULL,'71a12f10-af92-4eba-88f2-176a2cb3ae14'),(2050,'HHCM_died','HHCM Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM_died\n HHCM Died\n \n 2023-03-30 17:12:43 UTC\n \n 2023-03-30 17:13: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 2050\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 = 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 (3650) \n and b.voided = 0 \n ) \n\n','2023-03-30 19:12:43',4,'2023-03-30 19:13:08',4,0,NULL,NULL,NULL,'87c6de2e-d87a-430b-a15e-d5de45e36410'),(2051,'HHCM_lost','HHCM Lost','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM_lost\n HHCM Lost\n \n 2023-03-30 17:13:35 UTC\n \n 2023-03-30 17:14: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 2051\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 = 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 (2302) \n and b.voided = 0 \n ) \n\n','2023-03-30 19:13:35',4,'2023-03-30 19:14:00',4,0,NULL,NULL,NULL,'543f25df-61ec-4cec-847f-816fec3268ec'),(2052,'TB Females and Failed (Susceptible)','TB Females and Failed (Susceptible)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Females and Failed (Susceptible)\n TB Females and Failed (Susceptible)\n \n 2023-03-30 17:14:08 UTC\n \n 2023-03-30 17:14: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 2052\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 -- Female \n and o.person_id in ( \n select o.person_id \n from obs o \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 where person.gender = 'F' \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-03-30 19:14:08',4,'2023-03-30 19:14:24',4,0,NULL,NULL,NULL,'d1085653-8aca-440b-ae5c-d899217ef3b5'),(2053,'HHCM_moved','HHCM Moved','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM_moved\n HHCM Moved\n \n 2023-03-30 17:14:34 UTC\n \n 2023-03-30 17:14:52 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 2053\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 = 3777 \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-03-30 19:14:34',4,'2023-03-30 19:14:52',4,0,NULL,NULL,NULL,'43bc5260-c525-4968-a427-01e7febdfef1'),(2054,'TB Females and Moved to SecondLine','TB Females and Moved to SecondLine','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Females and Moved to SecondLine\n TB Females and Moved to SecondLine\n \n 2023-03-30 17:14:53 UTC\n \n 2023-03-30 17:15: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 2054\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 -- Female \n and o.person_id in ( \n select o.person_id \n from obs o \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 where person.gender = 'F' \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-03-30 19:14:53',4,'2023-03-30 19:15:09',4,0,NULL,NULL,NULL,'56836385-8ef8-49a4-bdc7-e7ac24baadb9'),(2055,'TB Females and Not Evaluated','TB Females and Not Evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Females and Not Evaluated\n TB Females and Not Evaluated\n \n 2023-03-30 17:15:40 UTC\n \n 2023-03-30 17:16: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 2055\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 -- Female \n and o.person_id in ( \n select o.person_id \n from obs o \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 where person.gender = 'F' \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,2242,3650,2302,3793,3794) \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 19:15:40',4,'2023-03-30 19:16:46',4,0,NULL,NULL,NULL,'d1ccfc19-7910-4d71-8ba4-1b31cfbc17b7'),(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-12-20 07:10: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 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 16:20:07',4,'2023-12-20 09:10:01',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-12-20 07:15: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 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 17:45:38',4,'2023-12-20 09:15:07',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'); -INSERT INTO `serialized_object` VALUES (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'),(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 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:51:33 UTC\n \n 2023-12-20 07: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 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-12-20 09:08:34',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'); -INSERT INTO `serialized_object` VALUES (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'),(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'); -INSERT INTO `serialized_object` VALUES (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'),(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 2024-04-25 10:31: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 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 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 in (10,19) \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 18:10:58',4,'2024-04-25 16:01:31',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 2024-02-06 12:38: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 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 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 18:11:53',4,'2024-02-06 18:08:12',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 2024-02-06 10:21: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 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(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.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 18:12:21',4,'2024-02-06 15:51:22',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 2024-02-06 12: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 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 in (4189,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 18:21:29',4,'2024-02-06 18:10:40',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 2024-02-06 09:57: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 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(:startDate as date) \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(:startDate as date) \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 14:09:02',4,'2024-02-06 15:27:28',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'),(2600,'Contacts of TB Patients','Contacts of TB Patients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB Patients\n Contacts of TB Patients\n \n 2024-02-27 09:43:12 UTC\n \n 2024-02-27 10:34: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 2600\n select contact.person_id \n from \n (select B.person_id, B.obs_datetime \n from obs B \n inner join \n (select person_id, max(obs_datetime) as latest_consultation \n from obs where concept_id = 5926 \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.latest_consultation = B.obs_datetime \n where concept_id = 5962 and value_coded = 2146 \n and A.latest_consultation = B.obs_datetime \n and voided = 0 \n group by B.person_id \n ) as contact\n','2024-02-27 15:13:12',4,'2024-02-27 16:04:55',4,0,NULL,NULL,NULL,'f74fefb2-b6d4-4c26-b214-fdb965aeb103'),(2601,'Contacts of TB Patients screened for TB','Contacts of TB Patients screened for TB','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB Patients screened for TB\n Contacts of TB Patients screened for TB\n \n 2024-02-27 10:35:41 UTC\n \n 2024-02-27 10:36: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 2601\n select contact.person_id \n from \n (select B.person_id \n from obs B \n inner join \n (select person_id, max(obs_datetime) as latest_consultation \n from obs where concept_id = 5904 \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.latest_consultation = B.obs_datetime \n where concept_id = 5962 and value_coded = 2146 \n and A.latest_consultation = B.obs_datetime \n and voided = 0 \n group by B.person_id \n ) as contact\n','2024-02-27 16:05:41',4,'2024-02-27 16:06:09',4,0,NULL,NULL,NULL,'6733708e-c472-4c84-89a2-13e0938a8360'),(2602,'Presumptive TB contacts with bacteriologic result(s)','Presumptive TB contacts with bacteriologic test result (s)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Presumptive TB contacts with bacteriologic result(s)\n Presumptive TB contacts with bacteriologic test result (s)\n \n 2024-02-27 14:08:31 UTC\n \n 2024-02-27 14: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 2602\n \n select distinct Id \n FROM \n ( \n -- Bacteriologically confirmed Genotypic test results and Phenotypic test results \n select distinct person_id as Id \n From obs o \n where o.concept_id in (3814, 3815) \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.voided = 0 \n \n -- MTB not Detected \n and o.person_id in \n ( \n select distinct o.person_id \n from obs o \n inner join \n ( \n select oss.person_id as 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 in (5954,5433,5955,5956,5959) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.Id = o.person_id \n where o.concept_id in (3787,3805,3840,5957) \n and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n \n ) \n \n ) As Pulmonary_Bacteriologic\n','2024-02-27 19:38:31',4,'2024-02-27 19:46:55',4,0,NULL,NULL,NULL,'5c82cebb-b76f-4acd-a416-752578f29546'),(2603,'Contacts of TB Patients who are positive to a bacteriologic test ','Contacts of TB Patients who are positive to a bacteriologic test ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB Patients who are positive to a bacteriologic test \n Contacts of TB Patients who are positive to a bacteriologic test \n \n 2024-02-27 14:17:57 UTC\n \n 2024-02-27 17:56: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 2603\n select distinct Id \n FROM \n ( \n -- Bacteriologically results \n select distinct person_id as Id \n From obs o \n where o.concept_id = 5953 \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.voided = 0 \n \n -- MTB Detected \n and o.person_id in \n ( \n select distinct o.person_id \n from obs o \n inner join \n ( \n select oss.person_id as 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 in (5954,5433,5955,5956,5959) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.Id = o.person_id \n where o.concept_id in (3787,3805,3840,5957) \n and o.value_coded in (3816,3817,3718, 1738, 3828,3829,3830, 3831, 3832,3833,3834, 3835,3836, 3837,3838,3839) \n and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n \n ) \n \n ) As Pulmonary_Bacteriologic\n','2024-02-27 19:47:57',4,'2024-02-27 23:26:03',4,0,NULL,NULL,NULL,'c632d1d1-ddd1-40ca-bdfd-8df133511db3'),(2604,'Contacts of TB Patients who are positive bacteriologic test & started TB treatment','Contacts of TB Patients who are positive to a bacteriologic test and started on TB treatment','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB Patients who are positive bacteriologic test & started TB treatment\n Contacts of TB Patients who are positive to a bacteriologic test and started on TB treatment\n \n 2024-02-27 18:19:38 UTC\n \n 2024-02-27 18:20: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 2604\n select distinct Id \n FROM \n ( \n -- Bacteriologically results \n select distinct person_id as Id \n From obs o \n where o.concept_id = 5953 \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.voided = 0 \n \n -- MTB Detected \n and o.person_id in \n ( \n select distinct o.person_id \n from obs o \n inner join \n ( \n select oss.person_id as 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 in (5954,5433,5955,5956,5959) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.Id = o.person_id \n where o.concept_id in (3787,3805,3840,5957) \n and o.value_coded in (3816,3817,3718, 1738, 3828,3829,3830, 3831, 3832,3833,3834, 3835,3836, 3837,3838,3839) \n and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n \n ) \n \n ) As Pulmonary_Bacteriologic \n inner join ( \n select ob.person_id as pId \n FROM obs ob \n -- Pulmonary TB \n where ob.concept_id = 2237 \n AND cast(ob.value_datetime as date) >= CAST(:startDate AS DATE) \n and cast(ob.value_datetime as date) <= CAST(:endDate AS DATE) \n and ob.voided = 0 \n ) as Pulmonary \n on Pulmonary_Bacteriologic.Id = Pulmonary.pId\n','2024-02-27 23:49:38',4,'2024-02-27 23:50:06',4,0,NULL,NULL,NULL,'d2360af2-f13b-4b10-978f-5f230a0a83d7'),(2605,'Contacts of TB patients - Presumptive','Contacts of TB patients who have one or more signs and symptoms of TB (Presumptive)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB patients - Presumptive\n Contacts of TB patients who have one or more signs and symptoms of TB (Presumptive)\n \n 2024-02-27 18:31:50 UTC\n \n 2024-02-27 18:32: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 2605\n select ob.person_id as pId \n FROM obs ob \n where ob.concept_id = 5940 \n AND cast(ob.obs_datetime as date) >= CAST(:startDate AS DATE) \n and cast(ob.obs_datetime as date) <= CAST(:endDate AS DATE) \n and ob.voided = 0\n','2024-02-28 00:01:50',4,'2024-02-28 00:02:42',4,0,NULL,NULL,NULL,'17e19631-0322-48e3-8a42-352880f64b8f'),(2606,'Detection_Age','TB detection age groups','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Detection_Age\n TB detection age groups\n \n 2024-02-27 18:42:36 UTC\n \n 2024-02-27 18:47:04 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n 2606\n \n \n 15+years\n \n \n \n \n maxAge\n 120\n \n \n minAge\n 15\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 5-14yrs\n \n \n \n \n maxAge\n 14\n \n \n minAge\n 5\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n <5yrs\n \n \n \n \n maxAge\n 4\n \n \n minAge\n 0\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n','2024-02-28 00:12:36',4,'2024-02-28 00:17:04',4,0,NULL,NULL,NULL,'c12ee61b-5bc3-4476-866b-3a5a1ac37038'),(2607,'Contacts of TB Patients','Contacts of TB Patients','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB Patients\n Contacts of TB Patients\n \n 2024-02-27 18:52:39 UTC\n \n 2024-02-27 18: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 2607\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 00:22:39',4,'2024-02-28 00:24:05',4,0,NULL,NULL,NULL,'ec97d270-a1a8-4d2c-ae71-b6ffcb555781'),(2610,'Contacts of TB Patients screened for TB','Contacts of TB Patients screened for TB','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB Patients screened for TB\n Contacts of TB Patients screened for TB\n \n 2024-02-27 19:00:00 UTC\n \n 2024-02-27 19:00: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 2610\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 00:30:00',4,'2024-02-28 00:30:51',4,0,NULL,NULL,NULL,'1fefae20-e24c-4809-97a3-0bb2942ca618'),(2611,'Contacts of TB patients -Presumptive','Contacts of TB patients who have one or more signs and symptoms of TB (Presumptive)','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB patients -Presumptive\n Contacts of TB patients who have one or more signs and symptoms of TB (Presumptive)\n \n 2024-02-27 19:02:10 UTC\n \n 2024-02-27 19:03: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 2611\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 00:32:10',4,'2024-02-28 00:33:04',4,0,NULL,NULL,NULL,'61a06072-21c6-492d-94c7-f59c8980ce28'),(2612,'Presumptive TB contacts with bacteriologic test result (s)','Presumptive TB contacts with bacteriologic test result (s)','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Presumptive TB contacts with bacteriologic test result (s)\n Presumptive TB contacts with bacteriologic test result (s)\n \n 2024-02-27 19:04:19 UTC\n \n 2024-02-27 19:10: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 2612\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 00:34:19',4,'2024-02-28 00:40:31',4,0,NULL,NULL,NULL,'93c6d789-932b-4b13-903a-1c238427492c'),(2614,'Contacts of TB Patients who are positive to a bacteriologic test ','Contacts of TB Patients who are positive to a bacteriologic test ','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB Patients who are positive to a bacteriologic test \n Contacts of TB Patients who are positive to a bacteriologic test \n \n 2024-02-27 19:11:53 UTC\n \n 2024-02-27 19:12: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 2614\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 00:41:53',4,'2024-02-28 00:42:39',4,0,NULL,NULL,NULL,'ad43ca8a-5327-49d6-82a9-d4a5b532e54e'),(2615,'Contacts of TB Patients who are positive to a bacteriologic test and started on TB treatment','Contacts of TB Patients who are positive to a bacteriologic test and started on TB treatment','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB Patients who are positive to a bacteriologic test and started on TB treatment\n Contacts of TB Patients who are positive to a bacteriologic test and started on TB treatment\n \n 2024-02-27 19:13:47 UTC\n \n 2024-02-27 19: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 2615\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 00:43:47',4,'2024-02-28 00:44:36',4,0,NULL,NULL,NULL,'eecb27c4-5eea-4c61-8093-2e76f27c5733'),(2616,'TB Case Detection - Block 2: Contact Tracing and screening ','TB Case Detection - Block 2: Contact Tracing and screening ','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Case Detection - Block 2: Contact Tracing and screening \n TB Case Detection - Block 2: Contact Tracing and screening \n \n 2024-02-27 19:18:00 UTC\n \n 2024-02-27 19:18: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 2616\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','2024-02-28 00:48:00',4,'2024-02-28 00:48:20',4,0,NULL,NULL,NULL,'18beaf66-8afb-4c42-85f3-6a4f9e6e4c86'),(2617,'TB Case Detection - Block 2: Contact Tracing and screening 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 Case Detection - Block 2: Contact Tracing and screening Data Set\n \n 2024-02-27 19:18:20 UTC\n \n 2024-02-27 19: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 2617\n \n \n Detection_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n AlPosBacTB\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 AllBacRes\n \n \n \n \n \n \n \n \n \n AllConPres\n \n \n \n \n \n \n \n \n \n AllConScre\n \n \n \n \n \n \n \n \n \n AllContact\n \n \n \n \n \n \n \n \n \n AllPosBact\n \n \n \n \n \n \n \n \n \n BacRes5-14\n \n \n \n \n Detection_Age\n 5-14yrs\n \n \n \n \n \n BacRes<5ys\n \n \n \n \n Detection_Age\n <5yrs\n \n \n \n \n \n Con15+ys\n \n \n \n \n Detection_Age\n 15+years\n \n \n \n \n \n ConPre15+y\n \n \n \n \n \n \n ConPre5-14\n \n \n \n \n \n \n ConPres<5y\n \n \n \n \n \n \n ConScr15+y\n \n \n \n \n \n \n ConScr5-14\n \n \n \n \n \n \n ConScr<5ys\n \n \n \n \n \n \n Cont5-14ys\n \n \n \n \n \n \n Cont<5ys\n \n \n \n \n \n \n PoBaTB5-14\n \n \n \n \n \n \n PoBacTB15+\n \n \n \n \n \n \n PosBac15+y\n \n \n \n \n \n \n PosBac5-14\n \n \n \n \n \n \n PosBac<5ys\n \n \n \n \n \n \n PosBacTB<5\n \n \n \n \n \n \n','2024-02-28 00:48:20',4,'2024-02-28 01:18:21',4,0,NULL,NULL,NULL,'8ce17921-9b17-4c08-9bfc-679a5d0d56da'),(2618,'TB patients given 2RHZE/4RHE weighing 30-39kg','TB patients given 2RHZE/4RHE weighing 30-39kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing 30-39kg\n TB patients given 2RHZE/4RHE weighing 30-39kg\n \n 2024-02-28 09:00:45 UTC\n \n 2024-02-28 09:01: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 2618\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6002 -- 2RHZE/4RHE \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=30 and _weight < 40 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:30:45',4,'2024-02-28 14:31:30',4,0,NULL,NULL,NULL,'bce1bee1-bb3f-4a76-afef-2247f4cd563d'),(2619,'TB patients given 2RHZE/4RHE weighing 40-54kg','TB patients given 2RHZE/4RHE weighing 40-54kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing 40-54kg\n TB patients given 2RHZE/4RHE weighing 40-54kg\n \n 2024-02-28 09:03:00 UTC\n \n 2024-02-28 09:03: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 2619\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6002 -- 2RHZE/4RHE \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=40 and _weight < 55 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:33:00',4,'2024-02-28 14:33:22',4,0,NULL,NULL,NULL,'1e603efc-b71c-45c5-8c9b-8f3126d88455'),(2620,'TB patients given 2RHZE/4RHE weighing 55-70kg','TB patients given 2RHZE/4RHE weighing 55-70kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing 55-70kg\n TB patients given 2RHZE/4RHE weighing 55-70kg\n \n 2024-02-28 09:03:53 UTC\n \n 2024-02-28 09:04: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 2620\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6002 -- 2RHZE/4RHE \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=55 and _weight <= 70 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:33:53',4,'2024-02-28 14:34:42',4,0,NULL,NULL,NULL,'7a53ac46-5c90-4320-83ff-2f59647d980f'),(2621,'TB patients given 2RHZE/4RHE weighing > 70','TB patients given 2RHZE/4RHE weighing > 70','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing > 70\n TB patients given 2RHZE/4RHE weighing > 70\n \n 2024-02-28 09:05:44 UTC\n \n 2024-02-28 09: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 2621\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6002 -- 2RHZE/4RHE \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight > 70 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:35:44',4,'2024-02-28 14:36:26',4,0,NULL,NULL,NULL,'fe5b0998-1225-4b7e-b565-e15fa88e7ca7'),(2622,'TB patients given 2HPMZ/2HPM weighing 40-50kg','TB patients given 2HPMZ/2HPM weighing 40-50kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HPMZ/2HPM weighing 40-50kg\n TB patients given 2HPMZ/2HPM weighing 40-50kg\n \n 2024-02-28 09:08:25 UTC\n \n 2024-02-28 09:08: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 2622\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6003 -- 2HPMZ/2HPM \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=40 and _weight < 50 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 14:38:25',4,'2024-02-28 14:38:53',4,0,NULL,NULL,NULL,'97d1eb39-6c72-4cd7-85f2-a7667daea615'),(2623,'TB patients given 2HPMZ/2HPM weighing 50-65kg','TB patients given 2HPMZ/2HPM weighing 50-65kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HPMZ/2HPM weighing 50-65kg\n TB patients given 2HPMZ/2HPM weighing 50-65kg\n \n 2024-02-28 09:09:48 UTC\n \n 2024-02-28 09:10: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 2623\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6003 -- 2HPMZ/2HPM \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=50 and _weight < 65 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 14:39:48',4,'2024-02-28 14:40:58',4,0,NULL,NULL,NULL,'4698f622-e7a9-4dd9-8c2d-6af54419f71f'),(2624,'TB patients given 2HPMZ/2HPM weighing > 65kg','TB patients given 2HPMZ/2HPM weighing > 65kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HPMZ/2HPM weighing > 65kg\n TB patients given 2HPMZ/2HPM weighing > 65kg\n \n 2024-02-28 09:11:30 UTC\n \n 2024-02-28 09:12: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 2624\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6003 -- 2HPMZ/2HPM \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=65 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:41:30',4,'2024-02-28 14:42:01',4,0,NULL,NULL,NULL,'707a44a5-5cd1-46d8-9880-4c4396914acc'),(2625,'TB patients given 2RHZE/4HR weighing <2kg','TB patients given 2RHZE/4HR weighing <2kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing <2kg\n TB patients given 2RHZE/4HR weighing <2kg\n \n 2024-02-28 09:16:33 UTC\n \n 2024-02-28 09:18: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 2625\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight < 2 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 14:46:33',4,'2024-02-28 14:48:07',4,0,NULL,NULL,NULL,'4c663664-65db-4048-8554-4546b580ff2f'),(2626,'TB patients given 2RHZE/4HR weighing 2-2.9kg','TB patients given 2RHZE/4HR weighing 2-2.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 2-2.9kg\n TB patients given 2RHZE/4HR weighing 2-2.9kg\n \n 2024-02-28 09:17:03 UTC\n \n 2024-02-28 09:18: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 2626\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=2 and _weight <=2.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 14:47:03',4,'2024-02-28 14:48:56',4,0,NULL,NULL,NULL,'bcc6e6f5-8e74-4a51-bf4e-74f9aa16c937'),(2627,'TB patients given 2RHZE/4HR weighing 3-3.9kg','TB patients given 2RHZE/4HR weighing 3-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 3-3.9kg\n TB patients given 2RHZE/4HR weighing 3-3.9kg\n \n 2024-02-28 09:17:29 UTC\n \n 2024-02-28 09:19: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 2627\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=3 and _weight <=3.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 14:47:29',4,'2024-02-28 14:49:26',4,0,NULL,NULL,NULL,'5f931adb-9e99-4e78-a063-02bd6d424205'),(2628,'TB patients given 2RHZE/4HR weighing 4-7.9kg','TB patients given 2RHZE/4HR weighing 4-7.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 4-7.9kg\n TB patients given 2RHZE/4HR weighing 4-7.9kg\n \n 2024-02-28 09:20:41 UTC\n \n 2024-02-28 09: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 2628\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=4 and _weight <=7.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 14:50:41',4,'2024-02-28 14:52:44',4,0,NULL,NULL,NULL,'e45460ed-89cd-4be9-a60b-b3b96c18690c'),(2629,'TB patients given 2RHZE/4HR weighing 8-11.9kg','TB patients given 2RHZE/4HR weighing 8-11.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 8-11.9kg\n TB patients given 2RHZE/4HR weighing 8-11.9kg\n \n 2024-02-28 09:21:07 UTC\n \n 2024-02-28 09:23: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 2629\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=8 and _weight <=11.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 14:51:07',4,'2024-02-28 14:53:25',4,0,NULL,NULL,NULL,'abc8ec30-9c64-4b20-90d5-84d305425137'),(2630,'TB patients given 2RHZE/4HR weighing 12-15.9kg','TB patients given 2RHZE/4HR weighing 12-15.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 12-15.9kg\n TB patients given 2RHZE/4HR weighing 12-15.9kg\n \n 2024-02-28 09:21:43 UTC\n \n 2024-02-28 09:24: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 2630\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=12 and _weight <=15.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 14:51:43',4,'2024-02-28 14:54:08',4,0,NULL,NULL,NULL,'52ec3a8d-b3e6-41dc-aa67-2ff1a07dfd2d'),(2631,'TB patients given 2RHZE/4HR weighing 16-24.9kg','TB patients given 2RHZE/4HR weighing 16-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 16-24.9kg\n TB patients given 2RHZE/4HR weighing 16-24.9kg\n \n 2024-02-28 09:24:47 UTC\n \n 2024-02-28 09:26: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 2631\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=16 and _weight <=24.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:54:47',4,'2024-02-28 14:56:48',4,0,NULL,NULL,NULL,'aaaa184e-66a3-41ee-805d-63a160e900d7'),(2632,'TB patients given 2RHZE/4HR weighing 25-<30kg','TB patients given 2RHZE/4HR weighing 25-<30kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 25-<30kg\n TB patients given 2RHZE/4HR weighing 25-<30kg\n \n 2024-02-28 09:25:32 UTC\n \n 2024-02-28 09:27: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 2632\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=25 and _weight <30 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:55:32',4,'2024-02-28 14:57:11',4,0,NULL,NULL,NULL,'0f4326f5-cd2a-4800-a7cb-fe455816074e'),(2633,'TB patients given 2RHZE/4HR weighing 30-<35kg','TB patients given 2RHZE/4HR weighing 30-<35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 30-<35kg\n TB patients given 2RHZE/4HR weighing 30-<35kg\n \n 2024-02-28 09:25:58 UTC\n \n 2024-02-28 09:27: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 2633\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=30 and _weight <35 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:55:58',4,'2024-02-28 14:57:39',4,0,NULL,NULL,NULL,'a8c81b22-814f-4ec1-870c-a46e92de3ee2'),(2634,'TB patients given 2RHZE/4HR weighing 35-<50kg','TB patients given 2RHZE/4HR weighing 35-<50kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 35-<50kg\n TB patients given 2RHZE/4HR weighing 35-<50kg\n \n 2024-02-28 09:28:44 UTC\n \n 2024-02-28 09:30: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 2634\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=35 and _weight <50 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:58:44',4,'2024-02-28 15:00:43',4,0,NULL,NULL,NULL,'780376a9-7a64-41f5-8f4d-0bcae15e9ca9'),(2635,'TB patients given 2RHZE/4HR weighing 50-<65kg','TB patients given 2RHZE/4HR weighing 50-<65kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 50-<65kg\n TB patients given 2RHZE/4HR weighing 50-<65kg\n \n 2024-02-28 09:29:39 UTC\n \n 2024-02-28 09: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 2635\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=50 and _weight <65 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:59:39',4,'2024-02-28 15:01:03',4,0,NULL,NULL,NULL,'7adf4555-6be7-4db8-911c-41e8087ab25f'),(2636,'TB patients given 2RHZE/4HR weighing >65kg','TB patients given 2RHZE/4HR weighing >65kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing >65kg\n TB patients given 2RHZE/4HR weighing >65kg\n \n 2024-02-28 09:30:09 UTC\n \n 2024-02-28 09:31: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 2636\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=65 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:00:09',4,'2024-02-28 15:01:20',4,0,NULL,NULL,NULL,'3ba100cc-0cf9-491d-a702-3382611c1f47'),(2637,'TB patients given 2HRE/10HR weighing < 2kg','TB patients given 2HRE/10HR weighing < 2kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing < 2kg\n TB patients given 2HRE/10HR weighing < 2kg\n \n 2024-02-28 09:46:22 UTC\n \n 2024-02-28 09:47: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 2637\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight<2 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:16:22',4,'2024-02-28 15:17:53',4,0,NULL,NULL,NULL,'c7f2046d-c7a7-4d48-9c85-2a455c7dbdc0'),(2638,'TB patients given 2HRE/10HR weighing 2-2.9kg','TB patients given 2HRE/10HR weighing 2-2.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 2-2.9kg\n TB patients given 2HRE/10HR weighing 2-2.9kg\n \n 2024-02-28 09:46:56 UTC\n \n 2024-02-28 09:48: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 2638\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=2 and _weight <=2.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:16:56',4,'2024-02-28 15:18:18',4,0,NULL,NULL,NULL,'de0d0c97-70f7-4883-bc11-e831a85a64bd'),(2639,'TB patients given 2HRE/10HR weighing 3-3.9kg','TB patients given 2HRE/10HR weighing 3-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 3-3.9kg\n TB patients given 2HRE/10HR weighing 3-3.9kg\n \n 2024-02-28 09:47:20 UTC\n \n 2024-02-28 09:48: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 2639\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=3 and _weight <=3.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:17:20',4,'2024-02-28 15:18:37',4,0,NULL,NULL,NULL,'8a6d80b4-4f5f-416d-8242-73f18ca89178'),(2640,'TB patients given 2HRE/10HR weighing 4-7.9kg','TB patients given 2HRE/10HR weighing 4-7.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 4-7.9kg\n TB patients given 2HRE/10HR weighing 4-7.9kg\n \n 2024-02-28 09:49:19 UTC\n \n 2024-02-28 09:50: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 2640\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=4 and _weight <=7.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:19:19',4,'2024-02-28 15:20:56',4,0,NULL,NULL,NULL,'38551c29-6e79-4f40-9411-9beecdee568e'),(2641,'TB patients given 2HRE/10HR weighing 8-11.9kg','TB patients given 2HRE/10HR weighing 8-11.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 8-11.9kg\n TB patients given 2HRE/10HR weighing 8-11.9kg\n \n 2024-02-28 09:49:56 UTC\n \n 2024-02-28 09:51: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 2641\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=8 and _weight <=11.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:19:56',4,'2024-02-28 15:21:15',4,0,NULL,NULL,NULL,'59ff1d6e-fe8b-4ca9-9b15-10937a9fa334'),(2642,'TB patients given 2HRE/10HR weighing 12-15.9kg','TB patients given 2HRE/10HR weighing 12-15.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 12-15.9kg\n TB patients given 2HRE/10HR weighing 12-15.9kg\n \n 2024-02-28 09:50:27 UTC\n \n 2024-02-28 09:51: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 2642\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=12 and _weight <=15.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:20:27',4,'2024-02-28 15:21:35',4,0,NULL,NULL,NULL,'1fab63d8-a077-4f3d-b679-8ea75eefc879'),(2643,'TB patients given 2HRE/10HR weighing 16-24.9kg','TB patients given 2HRE/10HR weighing 16-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 16-24.9kg\n TB patients given 2HRE/10HR weighing 16-24.9kg\n \n 2024-02-28 09:52:51 UTC\n \n 2024-02-28 09:54: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 2643\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=16 and _weight <=24.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:22:51',4,'2024-02-28 15:24:31',4,0,NULL,NULL,NULL,'e3ca9790-a1cc-4ede-adb2-2adf7417ef0e'),(2644,'TB patients given 2HRE/10HR weighing 25-<30kg','TB patients given 2HRE/10HR weighing 25-<30kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 25-<30kg\n TB patients given 2HRE/10HR weighing 25-<30kg\n \n 2024-02-28 09:53:35 UTC\n \n 2024-02-28 09:54: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 2644\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=25 and _weight <30 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:23:35',4,'2024-02-28 15:24:52',4,0,NULL,NULL,NULL,'61d82671-e514-447c-9f93-6ff18cefcc43'),(2645,'TB patients given 2HRE/10HR weighing 30-<35kg','TB patients given 2HRE/10HR weighing 30-<35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 30-<35kg\n TB patients given 2HRE/10HR weighing 30-<35kg\n \n 2024-02-28 09:53:58 UTC\n \n 2024-02-28 09:55: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 2645\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=30 and _weight <35 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:23:58',4,'2024-02-28 15:25:23',4,0,NULL,NULL,NULL,'ba68f071-b28c-4593-9eb5-d766c4059246'),(2646,'TB patients given 2HRE/10HR weighing 35-<50kg','TB patients given 2HRE/10HR weighing 35-<50kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 35-<50kg\n TB patients given 2HRE/10HR weighing 35-<50kg\n \n 2024-02-28 09:56:05 UTC\n \n 2024-02-28 09:57: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 2646\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=35 and _weight <50 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:26:05',4,'2024-02-28 15:27:36',4,0,NULL,NULL,NULL,'97a65448-6d14-44c7-b5f6-c9239129cc04'),(2647,'TB patients given 2HRE/10HR weighing 50-<65kg','TB patients given 2HRE/10HR weighing 50-<65kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 50-<65kg\n TB patients given 2HRE/10HR weighing 50-<65kg\n \n 2024-02-28 09:58:05 UTC\n \n 2024-02-28 09:59: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 2647\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=50 and _weight <65 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:28:05',4,'2024-02-28 15:29:08',4,0,NULL,NULL,NULL,'d55f2b31-4ae3-474d-888a-e00f28cb793d'),(2648,'TB patients given 2HRE/10HR weighing > 65kg','TB patients given 2HRE/10HR weighing > 65kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing > 65kg\n TB patients given 2HRE/10HR weighing > 65kg\n \n 2024-02-28 09:58:37 UTC\n \n 2024-02-28 09: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 2648\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=65 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:28:37',4,'2024-02-28 15:29:30',4,0,NULL,NULL,NULL,'1f23c88a-059b-4f38-b2eb-fc6799b4f222'),(2649,'TB patients given 2RHZE/2HR weighing < 2kg','TB patients given 2RHZE/2HR weighing < 2kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing < 2kg\n TB patients given 2RHZE/2HR weighing < 2kg\n \n 2024-02-28 10:01:29 UTC\n \n 2024-02-28 10:02: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 2649\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight<2 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 15:31:29',4,'2024-02-28 15:32:50',4,0,NULL,NULL,NULL,'8d42e0e8-c79a-4f69-abc6-4fa27df65a30'),(2650,'TB patients given 2RHZE/2HR weighing 2-2.9kg','TB patients given 2RHZE/2HR weighing 2-2.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 2-2.9kg\n TB patients given 2RHZE/2HR weighing 2-2.9kg\n \n 2024-02-28 10:01:54 UTC\n \n 2024-02-28 10:03: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 2650\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=2 and _weight <=2.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 15:31:54',4,'2024-02-28 15:33:05',4,0,NULL,NULL,NULL,'b2fe9c79-18fe-49be-aa3c-b7bfbd65ba1c'),(2651,'TB patients given 2RHZE/2HR weighing 3-3.9kg','TB patients given 2RHZE/2HR weighing 3-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 3-3.9kg\n TB patients given 2RHZE/2HR weighing 3-3.9kg\n \n 2024-02-28 10:02:16 UTC\n \n 2024-02-28 10:03: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 2651\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=3 and _weight <=3.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 15:32:16',4,'2024-02-28 15:33:21',4,0,NULL,NULL,NULL,'22385e11-6674-42cb-9da8-78d2340fb975'),(2652,'B patients given 2RHZE/2HR weighing 4-7.9kg','B patients given 2RHZE/2HR weighing 4-7.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n B patients given 2RHZE/2HR weighing 4-7.9kg\n B patients given 2RHZE/2HR weighing 4-7.9kg\n \n 2024-02-28 10:04:18 UTC\n \n 2024-02-28 10:05: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 2652\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=4 and _weight <=7.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 15:34:18',4,'2024-02-28 15:35:37',4,0,NULL,NULL,NULL,'356dbe3c-dd76-4e39-b486-3e86492b4eb0'),(2653,'B patients given 2RHZE/2HR weighing 8-11.9kg','B patients given 2RHZE/2HR weighing 8-11.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n B patients given 2RHZE/2HR weighing 8-11.9kg\n B patients given 2RHZE/2HR weighing 8-11.9kg\n \n 2024-02-28 10:04:50 UTC\n \n 2024-02-28 10:06: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 2653\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=8 and _weight <=11.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 15:34:50',4,'2024-02-28 15:36:00',4,0,NULL,NULL,NULL,'3d88ce54-fe6f-45ec-9628-303ede656df6'),(2654,'B patients given 2RHZE/2HR weighing 12-15.9kg','B patients given 2RHZE/2HR weighing 12-15.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n B patients given 2RHZE/2HR weighing 12-15.9kg\n B patients given 2RHZE/2HR weighing 12-15.9kg\n \n 2024-02-28 10:05:14 UTC\n \n 2024-02-28 10:06: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 2654\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=12 and _weight <=15.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 15:35:14',4,'2024-02-28 15:36:38',4,0,NULL,NULL,NULL,'f072dc00-cc6a-4c1d-b049-3d71fdd7c418'),(2655,'TB patients given 2RHZE/2HR weighing 4-7.9kg','TB patients given 2RHZE/2HR weighing 4-7.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 4-7.9kg\n TB patients given 2RHZE/2HR weighing 4-7.9kg\n \n 2024-02-28 10:10:03 UTC\n \n 2024-02-28 10:11: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 2655\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=4 and _weight <=7.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:40:03',4,'2024-02-28 15:41:16',4,0,NULL,NULL,NULL,'5d170b44-4744-44a0-8b5c-9a147276a165'),(2656,'TB patients given 2RHZE/2HR weighing 8-11.9kg','TB patients given 2RHZE/2HR weighing 8-11.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 8-11.9kg\n TB patients given 2RHZE/2HR weighing 8-11.9kg\n \n 2024-02-28 10:10:27 UTC\n \n 2024-02-28 10:11: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 2656\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=8 and _weight <=11.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:40:27',4,'2024-02-28 15:41:41',4,0,NULL,NULL,NULL,'4c12f685-7ba2-4a98-85d9-e8c718af019c'),(2657,'TB patients given 2RHZE/2HR weighing 12-15.9kg','TB patients given 2RHZE/2HR weighing 12-15.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 12-15.9kg\n TB patients given 2RHZE/2HR weighing 12-15.9kg\n \n 2024-02-28 10:10:49 UTC\n \n 2024-02-28 10:11: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 2657\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=12 and _weight <=15.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:40:49',4,'2024-02-28 15:41:59',4,0,NULL,NULL,NULL,'2da2a070-b7ba-4cd7-90c5-41cddf07a601'),(2658,'TB patients given 2RHZE/2HR weighing 16-24.9kg','TB patients given 2RHZE/2HR weighing 16-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 16-24.9kg\n TB patients given 2RHZE/2HR weighing 16-24.9kg\n \n 2024-02-28 10:12:34 UTC\n \n 2024-02-28 10:13: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 2658\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=16 and _weight <=24.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:42:34',4,'2024-02-28 15:43:58',4,0,NULL,NULL,NULL,'ecfd9cec-ff1f-4d86-b760-18ee712a0d36'),(2659,'TB patients given 2RHZE/2HR weighing 25-<30kg','TB patients given 2RHZE/2HR weighing 25-<30kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 25-<30kg\n TB patients given 2RHZE/2HR weighing 25-<30kg\n \n 2024-02-28 10:13:03 UTC\n \n 2024-02-28 10: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 2659\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=25 and _weight <30 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:43:03',4,'2024-02-28 15:44:18',4,0,NULL,NULL,NULL,'66c43d8e-18e2-41e5-a0b0-501a2b508a22'),(2660,'TB patients given 2RHZE/2HR weighing 30-<35kg','TB patients given 2RHZE/2HR weighing 30-<35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 30-<35kg\n TB patients given 2RHZE/2HR weighing 30-<35kg\n \n 2024-02-28 10:13:24 UTC\n \n 2024-02-28 10:14: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 2660\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=30 and _weight <35 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:43:24',4,'2024-02-28 15:44:35',4,0,NULL,NULL,NULL,'362a2af4-9cdc-4380-8631-4188d1354417'),(2661,'TB patients given 2RHZE/2HR weighing 35-<50kg','TB patients given 2RHZE/2HR weighing 35-<50kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 35-<50kg\n TB patients given 2RHZE/2HR weighing 35-<50kg\n \n 2024-02-28 10:15:06 UTC\n \n 2024-02-28 10:16: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 2661\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=35 and _weight <50 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:45:06',4,'2024-02-28 15:46:29',4,0,NULL,NULL,NULL,'210d7eb7-846b-42fe-a1e5-c47bc1450cb6'),(2662,'TB patients given 2RHZE/2HR weighing 50-<65kg','TB patients given 2RHZE/2HR weighing 50-<65kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 50-<65kg\n TB patients given 2RHZE/2HR weighing 50-<65kg\n \n 2024-02-28 10:15:34 UTC\n \n 2024-02-28 10:17: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 2662\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=50 and _weight <65 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:45:34',4,'2024-02-28 15:47:01',4,0,NULL,NULL,NULL,'8662ce61-9594-487c-9c1c-c683a2f95180'),(2663,'TB patients given 2RHZE/2HR weighing >65kg','TB patients given 2RHZE/2HR weighing >65kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing >65kg\n TB patients given 2RHZE/2HR weighing >65kg\n \n 2024-02-28 10:16:01 UTC\n \n 2024-02-28 10:36: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 2663\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=65 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:46:01',4,'2024-02-28 16:06:50',4,0,NULL,NULL,NULL,'d0c91360-93f7-4b62-a335-38d1f9e8e458'),(2664,'TB patients given 2HPMZ/2HPM weighing 40-50kg','TB patients given 2HPMZ/2HPM weighing 40-50kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HPMZ/2HPM weighing 40-50kg\n TB patients given 2HPMZ/2HPM weighing 40-50kg\n \n 2024-02-28 10:38:37 UTC\n \n 2024-02-28 10:40: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 2664\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:08:37',4,'2024-02-28 16:10:21',4,0,NULL,NULL,NULL,'267131cd-92f8-4d89-9153-7666479e3d96'),(2665,'TB patients given 2HPMZ/2HPM weighing 50-65kg','TB patients given 2HPMZ/2HPM weighing 50-65kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HPMZ/2HPM weighing 50-65kg\n TB patients given 2HPMZ/2HPM weighing 50-65kg\n \n 2024-02-28 10:40:43 UTC\n \n 2024-02-28 10:42: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 2665\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:10:43',4,'2024-02-28 16:12:38',4,0,NULL,NULL,NULL,'a2cce7b4-84b0-407c-a850-045310956d08'),(2666,'TB patients given 2HPMZ/2HPM weighing > 65kg','TB patients given 2HPMZ/2HPM weighing > 65kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HPMZ/2HPM weighing > 65kg\n TB patients given 2HPMZ/2HPM weighing > 65kg\n \n 2024-02-28 10:41:20 UTC\n \n 2024-02-28 10:43: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 2666\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:11:20',4,'2024-02-28 16:13:29',4,0,NULL,NULL,NULL,'66aa10a3-2291-4f8a-a710-af0231160982'),(2667,'TB patients given 2RHZE/4RHE weighing 30-39kg','TB patients given 2RHZE/4RHE weighing 30-39kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing 30-39kg\n TB patients given 2RHZE/4RHE weighing 30-39kg\n \n 2024-02-28 10:45:02 UTC\n \n 2024-02-28 10:47: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 2667\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:15:02',4,'2024-02-28 16:17:52',4,0,NULL,NULL,NULL,'507430f5-598c-485d-876a-0e1dbcdaea22'),(2668,'TB patients given 2RHZE/4RHE weighing 40-54kg','TB patients given 2RHZE/4RHE weighing 40-54kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing 40-54kg\n TB patients given 2RHZE/4RHE weighing 40-54kg\n \n 2024-02-28 10:46:01 UTC\n \n 2024-02-28 10: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 2668\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:16:01',4,'2024-02-28 16:18:15',4,0,NULL,NULL,NULL,'2d8b3440-8b64-4836-8097-0ee78b1421f9'),(2669,'TB patients given 2RHZE/4RHE weighing 55-70kg','TB patients given 2RHZE/4RHE weighing 55-70kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing 55-70kg\n TB patients given 2RHZE/4RHE weighing 55-70kg\n \n 2024-02-28 10:47:03 UTC\n \n COUNT\n','2024-02-28 16:17:03',4,NULL,NULL,0,NULL,NULL,NULL,'77aaf4be-b225-465a-b3dc-685757328958'),(2670,'TB patients given 2RHZE/4RHE weighing 55-70kg','TB patients given 2RHZE/4RHE weighing 55-70kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing 55-70kg\n TB patients given 2RHZE/4RHE weighing 55-70kg\n \n 2024-02-28 10:47:06 UTC\n \n 2024-02-28 10:49: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 2670\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:17:06',4,'2024-02-28 16:19:09',4,0,NULL,NULL,NULL,'4ca65f2c-58a1-46f2-be7d-d2e0b8b52eca'),(2671,'TB patients given 2RHZE/4RHE weighing > 70','TB patients given 2RHZE/4RHE weighing > 70','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing > 70\n TB patients given 2RHZE/4RHE weighing > 70\n \n 2024-02-28 10:48:45 UTC\n \n 2024-02-28 10:51: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 2671\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:18:45',4,'2024-02-28 16:21:07',4,0,NULL,NULL,NULL,'aacf0718-0185-42a7-8e9f-dc32a196d708'),(2672,'TB patients given 2RHZE/4HR weighing <2kg','TB patients given 2RHZE/4HR weighing <2kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing <2kg\n TB patients given 2RHZE/4HR weighing <2kg\n \n 2024-02-28 10:52:59 UTC\n \n 2024-02-28 10:55: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 2672\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:22:59',4,'2024-02-28 16:25:06',4,0,NULL,NULL,NULL,'fcef6215-4d11-4edb-a132-3a001295eac7'),(2673,'TB patients given 2RHZE/4HR weighing 2-2.9kg','TB patients given 2RHZE/4HR weighing 2-2.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 2-2.9kg\n TB patients given 2RHZE/4HR weighing 2-2.9kg\n \n 2024-02-28 10:53:34 UTC\n \n COUNT\n','2024-02-28 16:23:34',4,NULL,NULL,0,NULL,NULL,NULL,'a0f2d45a-30f4-4c5f-af64-3a6ccb151c33'),(2674,'TB patients given 2RHZE/4HR weighing 2-2.9kg','TB patients given 2RHZE/4HR weighing 2-2.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 2-2.9kg\n TB patients given 2RHZE/4HR weighing 2-2.9kg\n \n 2024-02-28 10:53:37 UTC\n \n 2024-02-28 10:57: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 2674\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:23:37',4,'2024-02-28 16:27:48',4,0,NULL,NULL,NULL,'a5aff9a2-2ff6-49ce-a1f9-5b2c07874d5c'),(2675,'TB patients given 2RHZE/4HR weighing 3-3.9kg','TB patients given 2RHZE/4HR weighing 3-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 3-3.9kg\n TB patients given 2RHZE/4HR weighing 3-3.9kg\n \n 2024-02-28 10:56:04 UTC\n \n 2024-02-28 10:58: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 2675\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:26:04',4,'2024-02-28 16:28:10',4,0,NULL,NULL,NULL,'06a8c0b0-b7a3-4443-b168-9816354d5519'),(2676,'TB patients given 2RHZE/4HR weighing 4-7.9kg','TB patients given 2RHZE/4HR weighing 4-7.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 4-7.9kg\n TB patients given 2RHZE/4HR weighing 4-7.9kg\n \n 2024-02-28 10:57:21 UTC\n \n 2024-02-28 10:59: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 2676\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:27:21',4,'2024-02-28 16:29:15',4,0,NULL,NULL,NULL,'fba7f805-6a0e-4a02-89fe-d8fe6491ff51'),(2677,'TB patients given 2RHZE/4HR weighing 8-11.9kg','TB patients given 2RHZE/4HR weighing 8-11.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 8-11.9kg\n TB patients given 2RHZE/4HR weighing 8-11.9kg\n \n 2024-02-28 10:59:49 UTC\n \n 2024-02-28 11:03: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 2677\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:29:49',4,'2024-02-28 16:33:52',4,0,NULL,NULL,NULL,'acb3c52b-cd20-4b33-8b0e-f8f8865d283c'),(2678,'TB patients given 2RHZE/4HR weighing 12-15.9kg','TB patients given 2RHZE/4HR weighing 12-15.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 12-15.9kg\n TB patients given 2RHZE/4HR weighing 12-15.9kg\n \n 2024-02-28 11:00:16 UTC\n \n 2024-02-28 11:04: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 2678\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:30:16',4,'2024-02-28 16:34:11',4,0,NULL,NULL,NULL,'af2dc223-8a19-46b1-b8ae-add6e943f891'),(2679,'TB patients given 2RHZE/4HR weighing 16-24.9kg','TB patients given 2RHZE/4HR weighing 16-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 16-24.9kg\n TB patients given 2RHZE/4HR weighing 16-24.9kg\n \n 2024-02-28 11:00:43 UTC\n \n 2024-02-28 11:04: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 2679\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:30:43',4,'2024-02-28 16:34:34',4,0,NULL,NULL,NULL,'693ddd70-5db7-46ba-8195-670f174b867f'),(2680,'TB patients given 2RHZE/4HR weighing 25-<30kg','TB patients given 2RHZE/4HR weighing 25-<30kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 25-<30kg\n TB patients given 2RHZE/4HR weighing 25-<30kg\n \n 2024-02-28 11:01:10 UTC\n \n 2024-02-28 11: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 2680\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:31:10',4,'2024-02-28 16:34:58',4,0,NULL,NULL,NULL,'2bd66740-4941-4932-8876-43e12c912ef0'),(2681,'TB patients given 2RHZE/4HR weighing 30-<35kg','TB patients given 2RHZE/4HR weighing 30-<35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 30-<35kg\n TB patients given 2RHZE/4HR weighing 30-<35kg\n \n 2024-02-28 11:05:44 UTC\n \n 2024-02-28 11:08: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 2681\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:35:44',4,'2024-02-28 16:38:52',4,0,NULL,NULL,NULL,'5201f808-7174-4785-b5a8-fb855cb1bc00'),(2682,'TB patients given 2RHZE/4HR weighing 35-<50kg','TB patients given 2RHZE/4HR weighing 35-<50kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 35-<50kg\n TB patients given 2RHZE/4HR weighing 35-<50kg\n \n 2024-02-28 11:07:34 UTC\n \n 2024-02-28 11:10: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 2682\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:37:34',4,'2024-02-28 16:40:34',4,0,NULL,NULL,NULL,'663aa7b1-0169-4cd3-aabb-1d33b0a54706'),(2683,'TB patients given 2RHZE/4HR weighing 50-<65kg','TB patients given 2RHZE/4HR weighing 50-<65kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 50-<65kg\n TB patients given 2RHZE/4HR weighing 50-<65kg\n \n 2024-02-28 11:07:58 UTC\n \n 2024-02-28 11: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 2683\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:37:58',4,'2024-02-28 16:40:49',4,0,NULL,NULL,NULL,'a07688e5-85a2-468b-9dc8-13a8c1100b47'),(2684,'TB patients given 2RHZE/4HR weighing >65kg','TB patients given 2RHZE/4HR weighing >65kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing >65kg\n TB patients given 2RHZE/4HR weighing >65kg\n \n 2024-02-28 11:08:27 UTC\n \n 2024-02-28 11:11: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 2684\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:38:27',4,'2024-02-28 16:41:07',4,0,NULL,NULL,NULL,'70b78a75-3be5-4dc5-a191-21ce2d9621ee'),(2685,'TB patients given 2HRE/10HR weighing < 2kg','TB patients given 2HRE/10HR weighing < 2kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing < 2kg\n TB patients given 2HRE/10HR weighing < 2kg\n \n 2024-02-28 13:08:41 UTC\n \n 2024-02-28 13:14: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 2685\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:38:41',4,'2024-02-28 18:44:55',4,0,NULL,NULL,NULL,'e8ffcdff-a39c-463b-8da6-a622ef5cefaf'),(2686,'TB patients given 2HRE/10HR weighing 2-2.9kg','TB patients given 2HRE/10HR weighing 2-2.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 2-2.9kg\n TB patients given 2HRE/10HR weighing 2-2.9kg\n \n 2024-02-28 13:09:10 UTC\n \n 2024-02-28 13:15: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 2686\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:39:10',4,'2024-02-28 18:45:22',4,0,NULL,NULL,NULL,'fd54220d-0eea-4c40-91d3-6842888ba3b5'),(2687,'TB patients given 2HRE/10HR weighing 3-3.9kg','TB patients given 2HRE/10HR weighing 3-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 3-3.9kg\n TB patients given 2HRE/10HR weighing 3-3.9kg\n \n 2024-02-28 13:09:39 UTC\n \n 2024-02-28 13:16: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 2687\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:39:39',4,'2024-02-28 18:46:19',4,0,NULL,NULL,NULL,'be84889c-0395-437b-9400-c2a7e8eb2ccf'),(2688,'TB patients given 2HRE/10HR weighing 4-7.9kg','TB patients given 2HRE/10HR weighing 4-7.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 4-7.9kg\n TB patients given 2HRE/10HR weighing 4-7.9kg\n \n 2024-02-28 13:10:10 UTC\n \n 2024-02-28 13: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 2688\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:40:10',4,'2024-02-28 18:46:40',4,0,NULL,NULL,NULL,'a204e666-8840-4614-bf83-af7330f68aaa'),(2689,'TB patients given 2HRE/10HR weighing 8-11.9kg','TB patients given 2HRE/10HR weighing 8-11.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 8-11.9kg\n TB patients given 2HRE/10HR weighing 8-11.9kg\n \n 2024-02-28 13:17:57 UTC\n \n 2024-02-28 13: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 2689\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:47:57',4,'2024-02-28 18:53:09',4,0,NULL,NULL,NULL,'139114c2-da7a-4749-89b4-e99e72994d81'),(2690,'TB patients given 2HRE/10HR weighing 12-15.9kg','TB patients given 2HRE/10HR weighing 12-15.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 12-15.9kg\n TB patients given 2HRE/10HR weighing 12-15.9kg\n \n 2024-02-28 13:19:00 UTC\n \n 2024-02-28 13:23: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 2690\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:49:00',4,'2024-02-28 18:53:27',4,0,NULL,NULL,NULL,'346da8a7-01a5-4c66-b438-15b66599e85d'),(2691,'TB patients given 2HRE/10HR weighing 16-24.9kg','TB patients given 2HRE/10HR weighing 16-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 16-24.9kg\n TB patients given 2HRE/10HR weighing 16-24.9kg\n \n 2024-02-28 13:19:33 UTC\n \n 2024-02-28 13:23: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 2691\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:49:33',4,'2024-02-28 18:53:55',4,0,NULL,NULL,NULL,'697a3eab-7fc5-4656-b90c-c8f503ba104e'),(2692,'TB patients given 2HRE/10HR weighing 25-<30kg','TB patients given 2HRE/10HR weighing 25-<30kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 25-<30kg\n TB patients given 2HRE/10HR weighing 25-<30kg\n \n 2024-02-28 13:20:00 UTC\n \n 2024-02-28 13: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 2692\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:50:00',4,'2024-02-28 18:54:21',4,0,NULL,NULL,NULL,'9aaeb85e-bf5b-4cfd-ac28-53cdb1bd4675'),(2693,'TB patients given 2HRE/10HR weighing 30-<35kg','TB patients given 2HRE/10HR weighing 30-<35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 30-<35kg\n TB patients given 2HRE/10HR weighing 30-<35kg\n \n 2024-02-28 13:26:24 UTC\n \n 2024-02-28 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 2693\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:56:24',4,'2024-02-28 19:00:36',4,0,NULL,NULL,NULL,'614b47d9-f71d-43f7-9f20-348a7341b425'),(2694,'TB patients given 2HRE/10HR weighing 35-<50kg','TB patients given 2HRE/10HR weighing 35-<50kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 35-<50kg\n TB patients given 2HRE/10HR weighing 35-<50kg\n \n 2024-02-28 13:27:03 UTC\n \n 2024-02-28 13:30: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 2694\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:57:03',4,'2024-02-28 19:00:58',4,0,NULL,NULL,NULL,'90a894c8-2f13-45b8-a9ff-718cc0b5d958'),(2695,'TB patients given 2HRE/10HR weighing 50-<65kg','TB patients given 2HRE/10HR weighing 50-<65kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 50-<65kg\n TB patients given 2HRE/10HR weighing 50-<65kg\n \n 2024-02-28 13:27:34 UTC\n \n 2024-02-28 13:31: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 2695\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:57:34',4,'2024-02-28 19:01:21',4,0,NULL,NULL,NULL,'310e9e3a-ae90-4d16-b876-81d55f05e601'),(2696,'TB patients given 2HRE/10HR weighing > 65kg','TB patients given 2HRE/10HR weighing > 65kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing > 65kg\n TB patients given 2HRE/10HR weighing > 65kg\n \n 2024-02-28 13:28:06 UTC\n \n 2024-02-28 13:31: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 2696\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:58:06',4,'2024-02-28 19:01:54',4,0,NULL,NULL,NULL,'fb06b275-034c-492c-bb27-10bef23fce0d'),(2697,'TB patients given 2RHZE/2HR weighing 2-2.9kg','TB patients given 2RHZE/2HR weighing 2-2.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 2-2.9kg\n TB patients given 2RHZE/2HR weighing 2-2.9kg\n \n 2024-02-28 13:38:38 UTC\n \n 2024-02-28 13:43: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 2697\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:08:38',4,'2024-02-28 19:13:00',4,0,NULL,NULL,NULL,'d5432933-9558-4f54-8f6e-abc5e9a0223b'),(2698,'TB patients given 2RHZE/2HR weighing 3-3.9kg','TB patients given 2RHZE/2HR weighing 3-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 3-3.9kg\n TB patients given 2RHZE/2HR weighing 3-3.9kg\n \n 2024-02-28 13:39:06 UTC\n \n 2024-02-28 13:48: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 2698\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:09:06',4,'2024-02-28 19:18:32',4,0,NULL,NULL,NULL,'9379b271-3680-47a4-a2be-8145d4e58fa0'),(2699,'TB patients given 2RHZE/2HR weighing 4-7.9kg','TB patients given 2RHZE/2HR weighing 4-7.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 4-7.9kg\n TB patients given 2RHZE/2HR weighing 4-7.9kg\n \n 2024-02-28 13:40:21 UTC\n \n 2024-02-28 13:48: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 2699\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:10:21',4,'2024-02-28 19:18:54',4,0,NULL,NULL,NULL,'c0729714-b7a1-4c39-b44a-dd01fcb1aecc'),(2700,'TB patients given 2RHZE/2HR weighing 8-11.9kg','TB patients given 2RHZE/2HR weighing 8-11.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 8-11.9kg\n TB patients given 2RHZE/2HR weighing 8-11.9kg\n \n 2024-02-28 13:42:30 UTC\n \n 2024-02-28 13:51: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 2700\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:12:30',4,'2024-02-28 19:21:42',4,0,NULL,NULL,NULL,'17375042-6d27-4096-a84b-bbe596fd7580'),(2701,'TB patients given 2RHZE/2HR weighing 12-15.9kg','TB patients given 2RHZE/2HR weighing 12-15.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 12-15.9kg\n TB patients given 2RHZE/2HR weighing 12-15.9kg\n \n 2024-02-28 14:06:02 UTC\n \n 2024-02-28 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 2701\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:36:02',4,'2024-02-28 19:44:26',4,0,NULL,NULL,NULL,'57ab8f00-8036-404f-9365-a541b14bca39'),(2702,'TB patients given 2RHZE/2HR weighing 16-24.9kg','TB patients given 2RHZE/2HR weighing 16-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 16-24.9kg\n TB patients given 2RHZE/2HR weighing 16-24.9kg\n \n 2024-02-28 14:07:12 UTC\n \n 2024-02-28 14:14: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 2702\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:37:12',4,'2024-02-28 19:44:09',4,0,NULL,NULL,NULL,'385c3355-f68b-4e23-9658-503b7056e688'),(2703,'TB patients given 2RHZE/2HR weighing 25-<30kg','TB patients given 2RHZE/2HR weighing 25-<30kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 25-<30kg\n TB patients given 2RHZE/2HR weighing 25-<30kg\n \n 2024-02-28 14:08:18 UTC\n \n 2024-02-28 14:13: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 2703\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:38:18',4,'2024-02-28 19:43:50',4,0,NULL,NULL,NULL,'ee38e990-b599-423f-8a88-51ab26f92f1c'),(2704,'TB patients given 2RHZE/2HR weighing < 2kg','TB patients given 2RHZE/2HR weighing < 2kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing < 2kg\n TB patients given 2RHZE/2HR weighing < 2kg\n \n 2024-02-28 14:10:05 UTC\n \n 2024-02-28 14:13: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 2704\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:40:05',4,'2024-02-28 19:43:31',4,0,NULL,NULL,NULL,'316b34a7-3579-4f2a-9c1e-59ab23cc0188'),(2705,'TB patients given 2RHZE/2HR weighing 30-<35kg','TB patients given 2RHZE/2HR weighing 30-<35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 30-<35kg\n TB patients given 2RHZE/2HR weighing 30-<35kg\n \n 2024-02-28 14:15:59 UTC\n \n COUNT\n','2024-02-28 19:45:59',4,NULL,NULL,0,NULL,NULL,NULL,'979c7335-0622-4f85-a7cf-2b64b47c7cbf'),(2706,'TB patients given 2RHZE/2HR weighing 30-<35kg','TB patients given 2RHZE/2HR weighing 30-<35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 30-<35kg\n TB patients given 2RHZE/2HR weighing 30-<35kg\n \n 2024-02-28 14:15:59 UTC\n \n 2024-02-28 14:19: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 2706\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:45:59',4,'2024-02-28 19:49:57',4,0,NULL,NULL,NULL,'db9dc079-bbf6-42dc-958e-c7c002c4e97c'),(2707,'TB patients given 2RHZE/2HR weighing 35-<50kg','TB patients given 2RHZE/2HR weighing 35-<50kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 35-<50kg\n TB patients given 2RHZE/2HR weighing 35-<50kg\n \n 2024-02-28 14:16:32 UTC\n \n 2024-02-28 14: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 2707\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:46:32',4,'2024-02-28 19:49:49',4,0,NULL,NULL,NULL,'cb160b1b-14c9-4b6d-b4f5-b0287f0ee584'),(2708,'TB patients given 2RHZE/2HR weighing 50-<65kg','TB patients given 2RHZE/2HR weighing 50-<65kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 50-<65kg\n TB patients given 2RHZE/2HR weighing 50-<65kg\n \n 2024-02-28 14:17:00 UTC\n \n 2024-02-28 14:21: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 2708\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:47:00',4,'2024-02-28 19:51:28',4,0,NULL,NULL,NULL,'a605a26b-e6b2-4e39-8568-adea9afbe93c'),(2709,'TB patients given 2RHZE/2HR weighing >65kg','TB patients given 2RHZE/2HR weighing >65kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing >65kg\n TB patients given 2RHZE/2HR weighing >65kg\n \n 2024-02-28 14:17:28 UTC\n \n 2024-02-28 14: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 2709\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:47:28',4,'2024-02-28 19:51:11',4,0,NULL,NULL,NULL,'79f70c54-0a3f-456a-bd82-f97868b651e3'),(2710,'TB Case Registration - Block 5','TB Case Registration - Block 5','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Case Registration - Block 5\n TB Case Registration - Block 5\n \n 2024-02-28 14:24:40 UTC\n \n 2024-02-28 14:25: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 2710\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','2024-02-28 19:54:40',4,'2024-02-28 19:55:12',4,0,NULL,NULL,NULL,'2043afe9-3ece-4901-a898-69be11ff0ac5'),(2711,'TB Case Registration - Block 5 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 Case Registration - Block 5 Data Set\n \n 2024-02-28 14:25:12 UTC\n \n 2024-02-29 09:52: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 2711\n \n \n \n 2HPMZ_40-5\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 2HPMZ_50-6\n \n \n \n \n \n \n \n \n \n 2HPMZ_65\n \n \n \n \n \n \n \n \n \n 2HRE/10H12\n \n \n \n \n \n \n \n \n \n 2HRE/10H16\n \n \n \n \n \n \n \n \n \n 2HRE/10H2-\n \n \n \n \n \n \n \n \n \n 2HRE/10H25\n \n \n \n \n \n \n \n \n \n 2HRE/10H3-\n \n \n \n \n \n \n \n \n \n 2HRE/10H30\n \n \n \n \n \n \n \n \n \n 2HRE/10H35\n \n \n \n \n \n \n \n \n \n 2HRE/10H4-\n \n \n \n \n \n \n \n \n \n 2HRE/10H50\n \n \n \n \n \n \n \n \n \n 2HRE/10H65\n \n \n \n \n \n \n \n \n \n 2HRE/10H8-\n \n \n \n \n \n \n \n \n \n 2HRE/10H<2\n \n \n \n \n \n \n \n \n \n 2RHZE/2H12\n \n \n \n \n \n \n \n \n \n 2RHZE/2H16\n \n \n \n \n \n \n \n \n \n 2RHZE/2H2-\n \n \n \n \n \n \n \n \n \n 2RHZE/2H25\n \n \n \n \n \n \n \n \n \n 2RHZE/2H3-\n \n \n \n \n \n \n \n \n \n 2RHZE/2H30\n \n \n \n \n \n \n \n \n \n 2RHZE/2H35\n \n \n \n \n \n \n \n \n \n 2RHZE/2H4-\n \n \n \n \n \n \n \n \n \n 2RHZE/2H50\n \n \n \n \n \n \n \n \n \n 2RHZE/2H65\n \n \n \n \n \n \n \n \n \n 2RHZE/2H8-\n \n \n \n \n \n \n \n \n \n 2RHZE/2H<2\n \n \n \n \n \n \n \n \n \n 2RHZE/4H12\n \n \n \n \n \n \n \n \n \n 2RHZE/4H16\n \n \n \n \n \n \n \n \n \n 2RHZE/4H2-\n \n \n \n \n \n \n \n \n \n 2RHZE/4H25\n \n \n \n \n \n \n \n \n \n 2RHZE/4H3-\n \n \n \n \n \n \n \n \n \n 2RHZE/4H30\n \n \n \n \n \n \n \n \n \n 2RHZE/4H35\n \n \n \n \n \n \n \n \n \n 2RHZE/4H4-\n \n \n \n \n \n \n \n \n \n 2RHZE/4H50\n \n \n \n \n \n \n \n \n \n 2RHZE/4H65\n \n \n \n \n \n \n \n \n \n 2RHZE/4H8-\n \n \n \n \n \n \n \n \n \n 2RHZE/4H<2\n \n \n \n \n \n \n \n \n \n 2RHZE/4R30\n \n \n \n \n \n \n \n \n \n 2RHZE/4R40\n \n \n \n \n \n \n \n \n \n 2RHZE/4R55\n \n \n \n \n \n \n \n \n \n 2RHZE/4R70\n \n \n \n \n \n \n \n \n \n','2024-02-28 19:55:12',4,'2024-02-29 15:22:37',4,0,NULL,NULL,NULL,'8be20f45-e610-469e-b1ba-5b16a08a151f'),(2712,'TB patients diagnosed with GeneXpert - sputum','TB patients diagnosed with GeneXpert - sputum','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with GeneXpert - sputum\n TB patients diagnosed with GeneXpert - sputum\n \n 2024-02-29 13:40:42 UTC\n \n 2024-02-29 13:41: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 2712\n select diagnosis.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_diagnosis \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 3814 and o.value_coded = 3824 -- GeneXpert Sputum \n 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 group by person_id)diagnosis \n\n','2024-02-29 19:10:42',4,'2024-02-29 19:11:05',4,0,NULL,NULL,NULL,'d8a123a8-d4f2-454d-be8b-bb9ccd11c979'),(2713,'TB patients diagnosed with LPA','TB patients diagnosed with LPA','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with LPA\n TB patients diagnosed with LPA\n \n 2024-02-29 13:42:00 UTC\n \n 2024-02-29 13: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 2713\n select diagnosis.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_diagnosis \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 3814 and o.value_coded = 3825 -- LPA \n 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 group by person_id)diagnosis\n','2024-02-29 19:12:00',4,'2024-02-29 19:12:37',4,0,NULL,NULL,NULL,'dbc7ab7e-b251-43e3-b9fc-78250f1dc6d2'),(2714,'TB patients diagnosed with smear microscopy','TB patients diagnosed with smear microscopy','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with smear microscopy\n TB patients diagnosed with smear microscopy\n \n 2024-02-29 13:47:25 UTC\n \n 2024-02-29 13:48: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 2714\n select diagnosis.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_diagnosis \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 3815 and o.value_coded = 3819 -- Smear microscopy \n 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 group by person_id)diagnosis\n','2024-02-29 19:17:25',4,'2024-02-29 19:18:20',4,0,NULL,NULL,NULL,'86c13563-ee30-4fbe-9ee2-3ba5baa43b99'),(2715,'TB patients diagnosed with Culture','TB patients diagnosed with Culture','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with Culture\n TB patients diagnosed with Culture\n \n 2024-02-29 13:50:16 UTC\n \n 2024-02-29 13:50: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 2715\n select diagnosis.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_diagnosis \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 3815 and o.value_coded = 3819 -- Smear microscopy \n 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 group by person_id)diagnosis\n','2024-02-29 19:20:16',4,'2024-02-29 19:20:55',4,0,NULL,NULL,NULL,'bb273381-7ea5-4c12-83fd-5f6e7e10e853'),(2716,'TB patients diagnosed with Culture','TB patients diagnosed with Culture','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with Culture\n TB patients diagnosed with Culture\n \n 2024-02-29 14:01:00 UTC\n \n 2024-02-29 14:06: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 2716\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-29 19:31:00',4,'2024-02-29 19:36:16',4,0,NULL,NULL,NULL,'b9218e8a-e0af-48a8-8107-dcc9a9a7a066'),(2717,'TB patients diagnosed with GeneXpert - sputum','TB patients diagnosed with GeneXpert - sputum','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with GeneXpert - sputum\n TB patients diagnosed with GeneXpert - sputum\n \n 2024-02-29 14:10:38 UTC\n \n COUNT\n','2024-02-29 19:40:38',4,NULL,NULL,0,NULL,NULL,NULL,'3a5d9a42-ab26-4205-b5a2-f2f53ea6c5bc'),(2718,'TB patients diagnosed with GeneXpert - sputum','TB patients diagnosed with GeneXpert - sputum','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with GeneXpert - sputum\n TB patients diagnosed with GeneXpert - sputum\n \n 2024-02-29 14:10:40 UTC\n \n 2024-02-29 14:35: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 2718\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-29 19:40:40',4,'2024-02-29 20:05:27',4,0,NULL,NULL,NULL,'a9c92543-222b-490d-bfa3-d2bcb6825eec'),(2719,'TB patients diagnosed with LPA','TB patients diagnosed with LPA','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with LPA\n TB patients diagnosed with LPA\n \n 2024-02-29 14:36:14 UTC\n \n 2024-02-29 14: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 2719\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-29 20:06:14',4,'2024-02-29 20:08:26',4,0,NULL,NULL,NULL,'7b6eb2f0-56a4-4c91-81c2-1e4abb4e98d2'),(2720,'TB patients diagnosed with smear microscopy','TB patients diagnosed with smear microscopy','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with smear microscopy\n TB patients diagnosed with smear microscopy\n \n 2024-02-29 14:37:25 UTC\n \n 2024-02-29 14:39: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 2720\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-29 20:07:25',4,'2024-02-29 20:09:11',4,0,NULL,NULL,NULL,'a27eacbd-b0a6-446f-950f-0402e720c4bb'),(2721,'TB Case Registration - Block 6','TB Case Registration - Block 6','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Case Registration - Block 6\n TB Case Registration - Block 6\n \n 2024-02-29 14:51:54 UTC\n \n 2024-02-29 14:52: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 2721\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','2024-02-29 20:21:54',4,'2024-02-29 20:22:47',4,0,NULL,NULL,NULL,'aeb7f90e-d61b-49b3-ae0f-6940f6d50c47'),(2724,'TB Case Registration - Block 6 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 Case Registration - Block 6 Data Set\n \n 2024-02-29 14:52:47 UTC\n \n 2024-02-29 15:07: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 2724\n \n \n \n Culture\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 GeneX_sput\n \n \n \n \n \n \n \n \n \n LPA\n \n \n \n \n \n \n \n \n \n Smear_micr\n \n \n \n \n \n \n \n \n \n','2024-02-29 20:22:47',4,'2024-02-29 20:37:45',4,0,NULL,NULL,NULL,'7db12160-92c5-4680-8972-988b5bdd2157'),(2725,'TB Case Registration - Block 6 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 Case Registration - Block 6 Data Set\n \n 2024-02-29 14:54: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 \n \n','2024-02-29 20:24:55',4,NULL,NULL,0,NULL,NULL,NULL,'dcdae370-ec79-44e6-9231-e5ab06942acf'),(2726,'TB Case Registration - Block 6 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 Case Registration - Block 6 Data Set\n \n 2024-02-29 14:55: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 \n \n','2024-02-29 20:25:05',4,NULL,NULL,0,NULL,NULL,NULL,'0613568a-14f8-488c-9721-431f1ab21e93'),(2727,'test - TAT','Test - TAT','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n test - TAT\n Test - TAT\n \n 2024-05-06 09:16:29 UTC\n \n 2024-05-06 10:36: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 2727\n select lab_orders.order_id \nfrom \n(select order_id, encounter_id, date_created \nfrom orders \nwhere concept_id = 5484 \nand voided = 0 \nand cast(date_created as date ) >= cast(:startDate as date) \nand cast(date_created as date ) <= cast(:endDate as date) \n)lab_orders \n \ninner join \n \n(Select result.order_id, Results, cast(obs_datetime as date) as result_date \n From \n ( \n select oss.person_id as pId, concat(oss.value_numeric, " ", "copies/ml") as Results, order_id, oss.obs_datetime \n from obs oss \n where oss.concept_id = 5485 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast(:startDate as date) \n group by oss.person_id \n \n UNION \n \n select oss.person_id as pId, "LDL" as Results, order_id, oss.obs_datetime \n from obs oss \n where oss.concept_id = 5489 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast(:startDate as date) \n group by oss.person_id \n \n )result \n )VL_result \n on VL_result.order_id = lab_orders.order_id \n \n\n','2024-05-06 14:46:29',4,'2024-05-06 16:06:56',4,0,NULL,NULL,NULL,'aba10bbe-5770-4127-b7b9-50826cffd0a5'); +INSERT INTO `serialized_object` VALUES (292,'Clients multi month 2d','2d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 2d\n 2d\n \n 2019-01-10 00:01:21 UTC\n \n 2019-05-09 09:29: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 292\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2209 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-10 00:01:21',4,'2019-05-09 09:29:04',4,0,NULL,NULL,NULL,'4452e974-8c6e-442e-bb45-d6e09d26765a'),(293,'Clients multi month 2e','2e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 2e\n 2e\n \n 2019-01-10 00:02:30 UTC\n \n 2019-05-09 09:30: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 293\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3674 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-10 00:02:30',4,'2019-05-09 09:30:24',4,0,NULL,NULL,NULL,'b70551ca-7dda-4d71-be21-852530c01b27'),(294,'Clients multi month 2f','2f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 2f\n 2f\n \n 2019-01-10 00:04:54 UTC\n \n 2019-05-09 09:31: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 294\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3675 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-10 00:04:54',4,'2019-05-09 09:31:55',4,0,NULL,NULL,NULL,'7b572190-3a8e-41fd-9f13-b857c5a2d5a6'),(295,'Clients multi month 2g','2g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 2g\n 2g\n \n 2019-01-10 00:05:54 UTC\n \n 2019-05-09 09:32: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 295\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3676 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-10 00:05:54',4,'2019-05-09 09:32:54',4,0,NULL,NULL,NULL,'5aa75e1d-5ae4-47d7-9b0b-e099ecdfbde9'),(296,'Clients multi month 2h','2h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 2h\n 2h\n \n 2019-01-10 00:06:48 UTC\n \n 2019-05-09 09: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 296\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3677 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-10 00:06:48',4,'2019-05-09 09:34:00',4,0,NULL,NULL,NULL,'e008404a-b1f1-442a-b667-5590a15ed2e9'),(297,'Clients multi month 3a','3a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 3a\n 3a\n \n 2019-01-10 00:08:01 UTC\n \n 2019-05-09 09:38: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 297\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-10 00:08:01',4,'2019-05-09 09:38:07',4,0,NULL,NULL,NULL,'88b2c868-7a1f-49e1-9277-e8dc122cafdd'),(298,'Clients multi month 3b','3b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 3b\n 3b\n \n 2019-01-10 00:09:34 UTC\n \n 2019-05-09 09:39: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 298\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-01-10 00:09:34',4,'2019-05-09 09:39:22',4,0,NULL,NULL,NULL,'c3243091-3cc9-4c2d-94d8-0b3c1b7c226a'),(299,'Clients seen 3a','3a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 3a\n 3a\n \n 2019-01-10 00:11:14 UTC\n \n 2019-05-08 10:25: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 299\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3683 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-01-10 00:11:14',4,'2019-05-08 10:25:34',4,0,NULL,NULL,NULL,'f635e506-399a-49f2-8016-c9b3410fb65d'),(300,'Clients seen 3b','3b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 3b\n 3b\n \n 2019-01-10 00:12:05 UTC\n \n 2019-05-08 10:37: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 300\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3684 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-01-10 00:12:05',4,'2019-05-08 10:37:48',4,0,NULL,NULL,NULL,'56b9db93-8aab-4bb7-9296-06b385249737'),(309,'CMP_ART Regimen 1month supply 6b','6b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 6b\n 6b\n \n 2019-01-10 16:41:42 UTC\n \n 2021-01-28 01: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 309\n Clients-seen-given-1-month-supply-6b OR Clients-newly-initiated-6b\n \n \n Clients-seen-given-1-month-supply-6b\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 Clients-newly-initiated-6b\n \n \n \n \n \n \n','2019-01-10 16:41:42',4,'2021-01-28 01:22:44',4,0,NULL,NULL,NULL,'36e870b9-ea69-42f4-af1c-ab0dc12652d1'),(310,'CMP_ART Regimen 1month supply 6c','6c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 6c\n 6c\n \n 2019-01-10 16:51:23 UTC\n \n 2021-01-28 01:29: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 310\n Clients-seen-given-1-month-supply-6c OR Clients-newly-initiated-6c\n \n \n Clients-seen-given-1-month-supply-6c\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 Clients-newly-initiated-6c\n \n \n \n \n \n \n','2019-01-10 16:51:23',4,'2021-01-28 01:29:53',4,0,NULL,NULL,NULL,'ab5ee2c6-b62a-4730-ab20-93402f758aba'),(311,'CMP_ART Regimen 1month supply 6d','6d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 6d\n 6d\n \n 2019-01-10 17:18:53 UTC\n \n 2021-01-28 01:36: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 311\n Clients-seen-given-1-month-supply-6d OR Clients-newly-initiated-6d\n \n \n Clients-seen-given-1-month-supply-6d\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 Clients-newly-initiated-6d\n \n \n \n \n \n \n','2019-01-10 17:18:53',4,'2021-01-28 01:36:27',4,0,NULL,NULL,NULL,'6fab4ceb-75e5-4687-ab3d-96d87493c83c'),(312,'CMP_ART Regimen 1month supply 6f','6f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 6f\n 6f\n \n 2019-01-10 17:30:56 UTC\n \n 2021-01-28 01:47: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 312\n Clients-newly-initiated-6f OR Clients-seen-given-1-month-supply-6f\n \n \n Clients-newly-initiated-6f\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 Clients-seen-given-1-month-supply-6f\n \n \n \n \n \n \n','2019-01-10 17:30:56',4,'2021-01-28 01:47:31',4,0,NULL,NULL,NULL,'5b53d187-636a-4b70-9d6a-56be8a998fe5'),(313,'CMP_ART Regimen 1month supply 5h','5h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 5h\n 5h\n \n 2019-01-10 17:40:48 UTC\n \n 2021-01-28 01:08: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 313\n Clients-newly-initiated-5h OR Clients-seen-given-1-month-supply-5h\n \n \n Clients-newly-initiated-5h\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 Clients-seen-given-1-month-supply-5h\n \n \n \n \n \n \n','2019-01-10 17:40:48',4,'2021-01-28 01:08:05',4,0,NULL,NULL,NULL,'817075e8-f801-429c-8ffa-b5b9ce9967ff'),(314,'CMP_ART Regimen 1month supply 4g','4g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4g\n 4g\n \n 2019-01-10 17:54:49 UTC\n \n 2021-01-27 23:58: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 314\n Clients-newly-initiated-4g OR Clients-seen-given-1-month-supply-4g\n \n \n Clients-newly-initiated-4g\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 Clients-seen-given-1-month-supply-4g\n \n \n \n \n \n \n','2019-01-10 17:54:49',4,'2021-01-27 23:58:55',4,0,NULL,NULL,NULL,'41d660e4-321c-42e4-995f-073161a5a1f0'),(315,'CMP_ART Regimen 1month supply 4h','4h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4h\n 4h\n \n 2019-01-10 18:05:16 UTC\n \n 2021-01-28 00:02: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 315\n Clients-newly-initiated-4h OR Clients-seen-given-1-month-supply-4h\n \n \n Clients-newly-initiated-4h\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 Clients-seen-given-1-month-supply-4h\n \n \n \n \n \n \n','2019-01-10 18:05:16',4,'2021-01-28 00:02:33',4,0,NULL,NULL,NULL,'0f5b1812-4fd6-4ded-b64e-16def8e64d81'),(316,'CMP_ART Regimen 1month supply 4j','4j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4j\n 4j\n \n 2019-01-10 18:17:31 UTC\n \n 2021-01-28 00:08: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 316\n Clients-newly-initiated-4j OR Clients-seen-given-1-month-supply-4j\n \n \n Clients-newly-initiated-4j\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 Clients-seen-given-1-month-supply-4j\n \n \n \n \n \n \n','2019-01-10 18:17:31',4,'2021-01-28 00:08:32',4,0,NULL,NULL,NULL,'9f6b4f25-5941-4798-ac05-75721fc60f5a'),(317,'CMP_ART Regimen 1month supply 4k','4k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4k\n 4k\n \n 2019-01-10 18:25:53 UTC\n \n 2021-01-28 00:14: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 317\n Clients-newly-initiated-4k OR Clients-seen-given-1-month-supply-4k\n \n \n Clients-newly-initiated-4k\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 Clients-seen-given-1-month-supply-4k\n \n \n \n \n \n \n','2019-01-10 18:25:53',4,'2021-01-28 00:14:25',4,0,NULL,NULL,NULL,'edfa3d6d-49de-4b92-80e3-06fbf1ac7064'),(318,'CMP_ART Regimen 1month supply 5c','5c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 5c\n 5c\n \n 2019-01-10 18:32:59 UTC\n \n 2021-01-28 00:32: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 318\n Clients-seen-given-1-month-supply-5c OR Clients-newly-initiated-5c\n \n \n Clients-seen-given-1-month-supply-5c\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 Clients-newly-initiated-5c\n \n \n \n \n \n \n','2019-01-10 18:32:59',4,'2021-01-28 00:32:35',4,0,NULL,NULL,NULL,'e7054506-95ba-4086-8f65-bd053e845fcf'),(319,'CMP_ART Regimen 1month supply 5d','5d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 5d\n 5d\n \n 2019-01-10 18:40:05 UTC\n \n 2021-01-28 00: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 319\n Clients-seen-given-1-month-supply-5d OR Clients-newly-initiated-5d\n \n \n Clients-seen-given-1-month-supply-5d\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 Clients-newly-initiated-5d\n \n \n \n \n \n \n','2019-01-10 18:40:05',4,'2021-01-28 00:37:52',4,0,NULL,NULL,NULL,'78bbfb25-ec26-40c2-8077-f300dabe0a0f'),(320,'CMP_ART Regimen 1month supply 5e','5e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 5e\n 5e\n \n 2019-01-10 18:44:24 UTC\n \n 2021-01-28 00:45: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 320\n Clients-newly-initiated-5e OR Clients-seen-given-1-month-supply-5e\n \n \n Clients-newly-initiated-5e\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 Clients-seen-given-1-month-supply-5e\n \n \n \n \n \n \n','2019-01-10 18:44:24',4,'2021-01-28 00:45:23',4,0,NULL,NULL,NULL,'4efdb85c-372c-4623-808d-7c9bc93eeff1'),(321,'CMP_ART Regimen 1month supply 5f','5f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 5f\n 5f\n \n 2019-01-10 18:49:28 UTC\n \n 2021-01-28 00:49: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 321\n Clients-newly-initiated-5f OR Clients-seen-given-1-month-supply-5f\n \n \n Clients-newly-initiated-5f\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 Clients-seen-given-1-month-supply-5f\n \n \n \n \n \n \n','2019-01-10 18:49:28',4,'2021-01-28 00:49:51',4,0,NULL,NULL,NULL,'2b09727b-e984-4c6f-841b-6e73c973622c'),(322,'Clients enroled on PreART exlcuding those with an ART start date','Combines client enrolled on PreART and excludes clients with an ART start date before end of period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients enroled on PreART exlcuding those with an ART start date\n Combines client enrolled on PreART and excludes clients with an ART start date before end of period\n \n 2019-01-23 08:29:09 UTC\n \n 2019-01-23 08:45: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 java.util.List\n true\n \n \n 322\n Date-enrolled-in-Pre-ART AND Clients-ever-enrolled-on-ART\n \n \n Date-enrolled-in-Pre-ART\n \n \n \n \n locationList\n ${location}\n \n \n value2\n ${endDate}\n \n \n value1\n ${startDate}\n \n \n \n \n \n Clients-ever-enrolled-on-ART\n \n \n \n \n locationList\n ${location}\n \n \n value1\n ${endDate}\n \n \n \n \n \n','2019-01-23 10:29:09',4,'2019-01-23 10:45:31',4,0,NULL,NULL,NULL,'1feca9b1-e0d7-4c4e-b898-0dc32b0cc71b'),(323,'CITest33: Clients enrolled on PreART','Testing','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITest33: Clients enrolled on PreART\n Testing\n \n 2019-01-23 08:37:15 UTC\n \n 2019-01-23 08:38: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 java.util.List\n true\n \n \n 323\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-01-23 10:37:15',4,'2019-01-23 10:38:29',4,0,NULL,NULL,NULL,'2e5bfe4e-6d66-4087-80db-71b46d544763'),(325,'Test Client Enrolled in PreART Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Test Client Enrolled in PreART Data Set\n \n 2019-01-23 08:39:18 UTC\n \n 2019-03-26 13:22: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 325\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 TXCurrPrev\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 20to24yrs\n \n \n \n \n \n','2019-01-23 08:39:18',4,'2019-03-26 13:22:19',4,0,NULL,NULL,NULL,'127b8507-13c4-4484-8957-880f8a03fbfd'),(326,'Pre-ART clients seen in previous months','preart multi month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pre-ART clients seen in previous months\n preart multi month\n \n 2019-01-23 10:54:36 UTC\n \n 2019-01-23 10:54: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 326\n','2019-01-23 12:54:36',4,'2019-01-23 12:54:46',4,0,NULL,NULL,NULL,'9becf662-98cd-4606-bbb2-e8dffabf1be0'),(328,'Clients not seen for unknown reasons','defaulters and missed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients not seen for unknown reasons\n defaulters and missed\n \n 2019-01-23 13:50:54 UTC\n \n 2019-02-03 11:02:39 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n 328\n ART-clients-with-Missed-Appointments OR ART-clients-who-Defaulted\n \n \n ART-clients-with-Missed-Appointments\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 ART-clients-who-Defaulted\n \n \n \n \n \n \n','2019-01-23 13:50:54',4,'2019-02-03 11:02:39',4,0,NULL,NULL,NULL,'b97be60d-0f0b-44bc-a6e6-fa57577e7889'),(329,'PreART Clients not initiated on ART','enrolled but no ART start date','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PreART Clients not initiated on ART\n enrolled but no ART start date\n \n 2019-01-24 12:41:36 UTC\n \n 2019-01-24 13:04:43 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 329\n select distinct 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.concept_id = 2223 \nand person_id not in ( \n select distinct person_id \n from obs os inner join location l on os.location_id = l.location_id \n where (os.location_id =:location or parent_location =:location) \n and os.concept_id = 2249 \n )\n','2019-01-24 12:41:36',4,'2019-01-24 13:04:43',4,0,NULL,NULL,NULL,'d0381567-7eab-475a-8525-9d9bd207ea6d'),(330,'New Persons enrolled in Pre ART','enrolled and no art start','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New Persons enrolled in Pre ART\n enrolled and no art start\n \n 2019-01-24 13:57:17 UTC\n \n 2019-01-31 20:30: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 330\n PreART-Clients-not-initiated-on-ART AND Date-enrolled-in-Pre-ART\n \n \n PreART-Clients-not-initiated-on-ART\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n \n \n \n Date-enrolled-in-Pre-ART-SQL\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','2019-01-24 13:57:17',4,'2019-01-31 20:30:08',4,0,NULL,NULL,NULL,'e7aaf7be-3ce1-4d84-9e78-2da603a5961f'),(331,'clients given multi month ARVs 2 or 3mnths','clients given multi month ARVs 2 or 3mnths','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients given multi month ARVs 2 or 3mnths\n clients given multi month ARVs 2 or 3mnths\n \n 2019-01-29 21:03:46 UTC\n \n 2019-03-29 07:50: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 331\n select distinct Id from \n (select distinct Id from \n ( \n (select distinct o.person_id AS 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 = 2250 \n and o.value_coded in (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n and o.voided = 0 \n and obs_datetime BETWEEN :startDate and DATE_ADD(:endDate, INTERVAL 1 DAY) \n ) \n \n UNION \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -28 DAY)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -28 DAY)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175,4176.4177,4245,4246,4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -28 DAY)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -28 DAY)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id = :location or parent_location = :location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE ( o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded in (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n ) \n) as regimen \nwhere Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 AND obs_datetime < DATE_ADD(:endDate, INTERVAL 1 DAY)) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate, INTERVAL 1 DAY) \n and dead = 1 \n ) \n )as final\n','2019-01-29 21:03:46',4,'2019-03-29 07:50:08',4,0,NULL,NULL,NULL,'c8709121-d393-4861-b808-559fd29dfd7d'),(332,'clients given multi month ARVs 3mnths','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients given multi month ARVs 3mnths\n \n \n 2019-01-29 21:28:52 UTC\n \n 2019-03-29 07:53: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 332\n select distinct Id from \n(select id from \n ( \n ( \n select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n ) \n \n UNION \n \n ( \n select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n ) \n \n UNION \n \n ( \n select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n ) \n \n UNION \n \n ( \n select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n ) \n \n UNION \n \n ( \n select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n ) \n \n UNION \n \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in(4175,4146,4177,4245,4246,4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id = :location or parent_location = :location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n \n ) \n \nUNION \n \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in(4175,4146,4177,4245,4246,4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id = :location or parent_location = :location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n \n ) \n \nUNION \n \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in(4175,4146,4177,4245,4246,4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id = :location or parent_location = :location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n \n ) \n \nUNION \n \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in(4175,4146,4177,4245,4246,4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id = :location or parent_location = :location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n \n ) \n \nUNION \n \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in(4175,4146,4177,4245,4246,4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id = :location or parent_location = :location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n \n ) \n \nUNION \n \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(DATE_ADD(:endDate,INTERVAL 1 DAY), INTERVAL -28 DAY)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(DATE_ADD(:endDate,INTERVAL 1 DAY), INTERVAL -28 DAY)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in(4175,4146,4177,4245,4246,4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id = :location or parent_location = :location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded IN (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n \n ) \n) as regimen \n \nwhere Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 AND obs_datetime < :endDate) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < :endDate \n and dead = 1 \n ) \n) \nas final\n','2019-01-29 21:28:52',4,'2019-03-29 07:53:17',4,0,NULL,NULL,NULL,'4cdbc901-cea1-4995-84b6-0b6d46c49e03'),(333,'Appointment NOT scheduled','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CodedObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Appointment NOT scheduled\n \n \n 2019-01-29 21:45:38 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n ANY\n \n \n \n \n NOT_IN\n \n \n \n','2019-01-29 21:45:38',4,NULL,NULL,0,NULL,NULL,NULL,'b3da29d2-311a-4264-bef4-5b1b0629704e'),(334,'Clients who picked up ARVs on time','Clients who picked up ARVs on time','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients who picked up ARVs on time\n Clients who picked up ARVs on time\n \n 2019-01-29 21:46:50 UTC\n \n 2019-03-29 08: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 334\n Clients-given-2weeks-ARV OR clients-given-multi-month-ARVs-3mnths OR clients-given-multi-month-ARVs-2-or-3mnths AND Clients-with-scheduled-appointments-SQL\n \n \n Clients-given-2weeks-ARV\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 clients-given-multi-month-ARVs-3mnths\n \n \n \n \n \n \n clients-given-multi-month-ARVs-2-or-3mnths\n \n \n \n \n \n \n Clients-with-scheduled-appointments-SQL\n \n \n \n \n \n \n','2019-01-29 21:46:50',4,'2019-03-29 08:00:58',4,0,NULL,NULL,NULL,'937a56fd-e654-414a-b1bb-9499ba8d99e5'),(335,'clients not on appointement','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients not on appointement\n \n \n 2019-01-29 21:53:00 UTC\n \n 2019-01-29 21:54: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 335\n COUNT\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n','2019-01-29 21:53:00',4,'2019-01-29 21:54:40',4,0,NULL,NULL,NULL,'eb1bf76e-95e8-474d-b856-05c69ce9bcdd'),(336,'clients given 2 or 3mnths ARVs','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients given 2 or 3mnths ARVs\n \n \n 2019-01-29 21:55:47 UTC\n \n 2019-01-29 21:56: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 336\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-01-29 21:55:47',4,'2019-01-29 21:56:53',4,0,NULL,NULL,NULL,'3c92647f-a1dd-4218-b440-3272663aa92d'),(337,'clients given 3mnths ARVs ','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients given 3mnths ARVs \n \n \n 2019-01-29 21:57:48 UTC\n \n 2019-01-29 21:58: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 337\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-01-29 21:57:48',4,'2019-01-29 21:58:37',4,0,NULL,NULL,NULL,'a4a2ee04-3761-40c9-b9b9-962fa502780d'),(338,'Clients on appointment','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients on appointment\n \n \n 2019-01-29 22:00:24 UTC\n \n 2019-01-29 22:01: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 338\n COUNT\n \n \n \n \n locationList\n ${location}\n \n \n onOrBefore\n ${endDate}\n \n \n onOrAfter\n ${startDate}\n \n \n \n','2019-01-29 22:00:24',4,'2019-01-29 22:01:08',4,0,NULL,NULL,NULL,'dc060565-40ef-4a71-b515-28cd018fb5d6'),(339,'Discordant couples SQL','Discordant couples','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Discordant couples SQL\n Discordant couples\n \n 2019-01-31 04:56:06 UTC\n \n 2019-01-31 05:06: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 339\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.concept_id = 4225 and o.value_coded = 2146\n','2019-01-31 04:56:06',4,'2019-01-31 05:06:40',4,0,NULL,NULL,NULL,'b3b772a7-7fc2-40d4-bbaa-8fe6e5eb9bd9'),(340,'ART Start date SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART Start date SQL\n \n \n 2019-01-31 08:49:55 UTC\n \n 2022-05-19 08:30: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 340\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 \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 NEWLY INITIATED ON ART \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 and o.voided = 0 \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 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 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.Age)\n','2019-01-31 08:49:55',4,'2022-05-19 08:30:24',4,0,NULL,NULL,NULL,'6f37715f-711c-48fa-8f56-e3360233d885'),(341,'ART restart date SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART restart date SQL\n \n \n 2019-01-31 09:40:55 UTC\n \n 2024-05-16 11:09: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 341\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND patient.voided = 0 AND o.voided = 0 \nAND o.person_id in( \n select person_id \n from \n (select o.person_id, max(o.obs_datetime) as seen_date, stopped_date \n from obs o \n inner join \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS stopped_date \n from obs oss \n inner join person p on oss.person_id=p.person_id \n and oss.concept_id = 3701 and oss.voided=0 -- ART stop date \n and cast(oss.obs_datetime as date) <= cast(:startDate as date) \n group by p.person_id \n ) as stopped_treatment \n on stopped_treatment.person_id = o.person_id \n where o.concept_id = 3753 and o.voided = 0 -- HIV followup form filled \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 having datediff(seen_date, stopped_date) > 30 \n )stopped_treatment) \n \nOR o.person_id in \n (select person_id \n from( \n (select o.person_id, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_datetime)), 20) AS restarted_date, stopped_date \n from obs o \n inner join \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS stopped_date \n from obs oss \n inner join person p on oss.person_id=p.person_id \n and oss.concept_id = 3701 and oss.voided=0 -- ART stop date \n and cast(oss.obs_datetime as date) <= cast(:startDate as date) \n group by p.person_id \n ) as stopped_treatment \n on stopped_treatment.person_id = o.person_id \n where o.concept_id = 3708 and o.voided = 0 -- Date Restarted ART \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 having datediff(restarted_date, stopped_date) > 30 \n \n ) \n )restarted) \n \n \n\n','2019-01-31 15:10:55',4,'2024-05-16 16:39:32',4,0,NULL,NULL,NULL,'f1a22112-f4e3-47eb-a3c8-beff0cc47bd4'),(342,'ART clients seen SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients seen SQL\n \n \n 2019-01-31 10:45:08 UTC\n \n 2024-02-15 09:25: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 342\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 \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 NEWLY INITIATED ON ART \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 and o.voided = 0 \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 ) \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 -7 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 \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 -7 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 \n and o.voided = 0 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n \n) \n \nORDER BY Clients_Seen.Age) \n\n','2019-01-31 16:15:08',4,'2024-02-15 14:55:27',4,0,NULL,NULL,NULL,'092398d1-86b9-4486-97ff-2864ef7871e9'),(343,'ART Clients transferred in SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART Clients transferred in SQL\n \n \n 2019-01-31 10:53:28 UTC\n \n 2022-04-28 13:11: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 343\n select distinct o.person_id \nfrom obs o \nwhere o.concept_id = 2253 and o.voided = 0 \nand MONTH(o.value_datetime) = MONTH(CAST(:endDate AS DATE)) \nand YEAR(o.value_datetime) = YEAR(CAST(:endDate AS DATE))\n','2019-01-31 10:53:28',4,'2022-04-28 13:11:52',4,0,NULL,NULL,NULL,'08280ca8-e857-4730-8350-950ab55aee95'),(344,'ART Clients transferred out SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART Clients transferred out SQL\n \n \n 2019-01-31 11:08:01 UTC\n \n 2022-08-25 10:12: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 344\n SELECT ID \n FROM \n ( \n select active_clients.person_id as 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 -- Patient Register \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 -- Follow-up date \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 MONTH (active_clients.latest_follow_up) = MONTH(cast(:endDate as date)) \n and YEAR (active_clients.latest_follow_up) = YEAR(cast(:endDate as date)) \n and DATEDIFF(CAST(:endDate AS DATE),latest_follow_up) >= 1 \n \n ) AS NOT_ACTIVE \nINNER JOIN \n \n( \n select B.person_id, B.obs_group_id \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 -- HIV Treatment and Care Progress Template \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 -- Transferred out \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n \n \n \n) AS TOUTS \non TOUTS.person_id = NOT_ACTIVE.ID \n \nAND NOT_ACTIVE.ID not in ( \n -- Died \n select distinct person_id \n from person \n where death_date <= CAST('2022-03-31' AS DATE) \n and dead = 1 \n \n ) \n\n','2019-01-31 11:08:01',4,'2022-08-25 10:12:07',4,0,NULL,NULL,NULL,'ab08b4d3-0971-427c-b3e9-8784299dbee7'),(345,'Tx Curr Previous months SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Tx Curr Previous months SQL\n \n \n 2019-01-31 11:21:16 UTC\n \n 2019-01-31 11: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 345\n clients-given-multi-month-ARVs-3mnths OR clients-given-multi-month-ARVs-2-or-3mnths\n \n \n clients-given-multi-month-ARVs-3mnths\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 clients-given-multi-month-ARVs-2-or-3mnths\n \n \n \n \n \n \n','2019-01-31 11:21:16',4,'2019-01-31 11:24:10',4,0,NULL,NULL,NULL,'9563340e-e1d1-4725-bff2-e89edbf454e2'),(346,'Clients given CTX SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given CTX SQL\n \n \n 2019-01-31 19:15:31 UTC\n \n 2019-02-03 11:38: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 346\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.concept_id = 3728 \nand o.value_numeric < 31 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate \n\n','2019-01-31 19:15:31',4,'2019-02-03 11:38:00',4,0,NULL,NULL,NULL,'e0ae8042-353d-41e9-a70f-4df0c6bcf58b'),(347,'Pre-ART Clients seen','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pre-ART Clients seen\n \n \n 2019-01-31 19:45:15 UTC\n \n 2019-01-31 20:04: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 347\n PreART-Clients-not-initiated-on-ART AND ART-clients-seen-SQL\n \n \n PreART-Clients-not-initiated-on-ART\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n \n \n \n ART-clients-seen-SQL\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','2019-01-31 19:45:15',4,'2019-01-31 20:04:38',4,0,NULL,NULL,NULL,'66c8ee04-f791-4774-84f7-597e039a4f94'),(348,'Date Confirmed HIV positive SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Date Confirmed HIV positive SQL\n \n \n 2019-01-31 20:09:36 UTC\n \n 2019-01-31 20:10: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 348\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.concept_id = 2222 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2019-01-31 20:09:36',4,'2019-01-31 20:10:20',4,0,NULL,NULL,NULL,'209fc83a-9c42-44aa-afe2-583e6e19cb56'),(349,'Date enrolled in Pre-ART SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Date enrolled in Pre-ART SQL\n \n \n 2019-01-31 20:24:03 UTC\n \n 2019-01-31 20:25: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 349\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.concept_id = 2223 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2019-01-31 20:24:03',4,'2019-01-31 20:25:29',4,0,NULL,NULL,NULL,'f2c9e963-4199-471b-aac4-23627e6d0d71'),(350,'Date enrolled in Pre-ART','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Date enrolled in Pre-ART\n \n \n 2019-01-31 20:39:42 UTC\n \n 2019-01-31 20:40: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 350\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-01-31 20:39:42',4,'2019-01-31 20:40:34',4,0,NULL,NULL,NULL,'5356e185-cedb-417f-a685-7a84a0e828f8'),(351,'HIV Care clients screened for TB SQL','HIV Care clients screened for TB SQL','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HIV Care clients screened for TB SQL\n HIV Care clients screened for TB SQL\n \n 2019-02-03 09:35:06 UTC\n \n 2019-02-03 09:45: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 351\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.concept_id = 3710 \nand o.value_coded in (3709,1876,3639) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2019-02-03 09:35:06',4,'2019-02-03 09:45:13',4,0,NULL,NULL,NULL,'0494f7f1-1aad-4673-b341-507b34e995e0'),(352,'Presumptive tb HIV care SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Presumptive tb HIV care SQL\n \n \n 2019-02-03 09:48:54 UTC\n \n 2019-02-03 09:49: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 352\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.concept_id = 3710 \nand o.value_coded in (1876) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2019-02-03 09:48:54',4,'2019-02-03 09:49:51',4,0,NULL,NULL,NULL,'f494b5e5-474b-4ef7-b987-77e6fbd1d5f9'),(353,'Diagnosed with TB and started treatment SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Diagnosed with TB and started treatment SQL\n \n \n 2019-02-03 09:53:12 UTC\n \n 2019-03-29 06: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 353\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.concept_id in (2237,2358) or (o.concept_id = 3789 and value_coded = 3790)) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2019-02-03 09:53:12',4,'2019-03-29 06:31:40',4,0,NULL,NULL,NULL,'e1467c7d-a287-43ab-ac11-8cc32e4a2723'),(354,'Clients with scheduled appointments SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with scheduled appointments SQL\n \n \n 2019-02-03 11:14:21 UTC\n \n 2019-03-29 07: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 354\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.concept_id = 3751 \nand o.value_coded = 2146 \n\n','2019-02-03 11:14:21',4,'2019-03-29 07:43:21',4,0,NULL,NULL,NULL,'1231a6ce-dd01-49ef-b585-9dbff0c4f663'),(355,'Clients given CTX 2mnths SQL ','CTX > 60','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given CTX 2mnths SQL \n CTX > 60\n \n 2019-02-03 11:39:04 UTC\n \n 2019-02-03 11:46: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 355\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.concept_id = 3728 \nand o.value_numeric > 31 \nand o.value_numeric < 62 \nand MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \nand YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \nand o.voided = 0\n','2019-02-03 11:39:04',4,'2019-02-03 11:46:11',4,0,NULL,NULL,NULL,'23c9999f-939a-477e-8343-782a5e9ba2b2'),(356,'Clients given CTX 3mnths SQL ','CTX <100','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given CTX 3mnths SQL \n CTX <100\n \n 2019-02-03 11:47:00 UTC\n \n 2019-02-04 07:05: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 356\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.concept_id = 3728 \nand o.value_numeric <= 100 \nand MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \nand YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \nand o.voided = 0;\n','2019-02-03 11:47:00',4,'2019-02-04 07:05:42',4,0,NULL,NULL,NULL,'9c8b100f-b3bf-469d-ae65-772cfc53c9ba'),(357,'Clients given curret and multi month CTX','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given curret and multi month CTX\n \n \n 2019-02-03 11:50:40 UTC\n \n 2019-02-03 11:53: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 357\n Clients-given-CTX-2mnths-SQL- OR Clients-given-CTX-3mnths-SQL- OR Clients-given-CTX-SQL\n \n \n Clients-given-CTX-2mnths-SQL-\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 Clients-given-CTX-3mnths-SQL-\n \n \n \n \n \n \n Clients-given-CTX-SQL\n \n \n \n \n \n \n','2019-02-03 11:50:40',4,'2019-02-03 11:53:12',4,0,NULL,NULL,NULL,'4a42a3bb-7340-496f-ab20-a29bb11953a7'),(358,'Newly enrolled in HIV Care,Started IPT SQL','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Newly enrolled in HIV Care,Started IPT SQL\n \n \n 2019-02-03 19:37:54 UTC\n \n 2019-02-03 20:31: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 358\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.concept_id = 2227 \nand o.value_coded = 2146 \nand o.person_id in \n( \nselect person_id \nfrom obs \nwhere concept_id = 2223 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate \n) \nand o.person_id not in \n( \nselect person_id \nfrom obs \nwhere concept_id = 2249 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate \n) \nand o.obs_datetime >=:startDate \nand o.obs_datetime <=:endDate;\n','2019-02-03 19:37:54',4,'2019-02-03 20:31:26',4,0,NULL,NULL,NULL,'2b679b8c-165e-4dbe-8b9d-e7f685a6dae8'),(359,'Clients newly started on ART and IPT','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly started on ART and IPT\n \n \n 2019-02-03 19:59:50 UTC\n \n 2019-02-03 20: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 359\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.concept_id = 2227 \nand o.value_coded = 2146 \nand o.person_id in \n( \nselect person_id \nfrom obs \nwhere concept_id = 2249 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate \n) \nand o.obs_datetime >=:startDate \nand o.obs_datetime <=:endDate;\n','2019-02-03 19:59:50',4,'2019-02-03 20:09:02',4,0,NULL,NULL,NULL,'a10eb64a-10db-4cc9-a69a-e9659e634918'),(360,'pre art test new diagnosed','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n pre art test new diagnosed\n \n \n 2019-02-04 07:51:40 UTC\n \n 2019-02-04 07:56: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 360\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.concept_id = 2222 \nand o.person_id in \n( \nselect person_id \nfrom obs \nwhere concept_id = 2223 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate \n) \nand o.person_id not in \n( \nselect person_id \nfrom obs \nwhere concept_id = 2249 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate \n) \nand o.obs_datetime >=:startDate \nand o.obs_datetime <=:endDate;\n','2019-02-04 07:51:40',4,'2019-02-04 07:56:11',4,0,NULL,NULL,NULL,'44860f5e-0ce8-466d-8c01-c2ff60737256'),(361,'pre art test newly enrolled','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n pre art test newly enrolled\n \n \n 2019-02-04 08:07:56 UTC\n \n 2019-02-04 08:14: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 361\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.concept_id = 2223 \nand o.person_id not in \n( \nselect person_id \nfrom obs \nwhere concept_id = 2249 \n) \nand o.obs_datetime >=:startDate \nand o.obs_datetime <=:endDate;\n','2019-02-04 08:07:56',4,'2019-02-04 08:14:46',4,0,NULL,NULL,NULL,'1796e0e3-bf74-436b-8b98-4258885a7d1f'),(362,'Clients seen in previous 1 through 6 months SQL','All clients seen in previous 1 through 6 months given multi month supply','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen in previous 1 through 6 months SQL\n All clients seen in previous 1 through 6 months given multi month supply\n \n 2019-02-04 13:45:38 UTC\n \n 2024-02-15 09:20: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 362\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 \n(SELECT Id \nFROM ( \n \n (SELECT Id, patientIdentifier , patientName, Age, Gender, age_group, 'Seen_Previous' AS 'Program_Status', sort_order \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.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 and voided = 0 \n and A.observation_id = B.obs_group_id \n and B.voided = 0 \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 and os.voided =0 \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 and os.voided = 0 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n \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)AS Seen_Prev)\n','2019-02-04 19:15:38',4,'2024-02-15 14:50:35',4,0,NULL,NULL,NULL,'6f3593ef-a36c-4d2c-a10b-801b5bc8596b'),(363,'Clients with baseline CD4 counts 12mnths','Clients with baseline CD4 counts 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with baseline CD4 counts 12mnths\n Clients with baseline CD4 counts 12mnths\n \n 2019-02-05 08:52:36 UTC\n \n 2019-02-05 08:53: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 363\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 10:52:36',4,'2019-02-05 10:53:32',4,0,NULL,NULL,NULL,'fa2725bc-529d-43a8-8153-815da5e1cfca'),(364,'Clients with baseline CD4 counts 6mnths','Clients with baseline CD4 counts 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with baseline CD4 counts 6mnths\n Clients with baseline CD4 counts 6mnths\n \n 2019-02-05 08:54:13 UTC\n \n 2019-02-05 08:57: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 364\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 10:54:13',4,'2019-02-05 10:57:42',4,0,NULL,NULL,NULL,'f47faba9-8813-4593-8f6a-a6fe13d0e378'),(365,'Clients still on original firstline 6mnths','Clients still on original firstline 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients still on original firstline 6mnths\n Clients still on original firstline 6mnths\n \n 2019-02-05 08:59:32 UTC\n \n 2019-02-05 09:00: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 365\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 10:59:32',4,'2019-02-05 11:00:54',4,0,NULL,NULL,NULL,'8b0102ef-3c90-49f8-8d7c-f49f3af9d70e'),(366,'Clients still on original firstline 12mnths','Clients still on original firstline 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients still on original firstline 12mnths\n Clients still on original firstline 12mnths\n \n 2019-02-05 09:01:30 UTC\n \n 2019-02-05 09:02: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 366\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:01:30',4,'2019-02-05 11:02:20',4,0,NULL,NULL,NULL,'63f43e63-76e4-4d5a-b680-5e1fb48a419d'),(367,'Clients on alternative 1st line 6mnths','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients on alternative 1st line 6mnths\n \n \n 2019-02-05 09:03:10 UTC\n \n 2019-02-05 09:05: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 367\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:03:10',4,'2019-02-05 11:05:30',4,0,NULL,NULL,NULL,'3512308a-d7a1-4695-bee3-fe760dd7da54'),(368,'Clients on alternative 1st line 12mnths','Clients on alternative 1st line 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients on alternative 1st line 12mnths\n Clients on alternative 1st line 12mnths\n \n 2019-02-05 09:06:09 UTC\n \n 2019-02-05 09:06: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 368\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:06:09',4,'2019-02-05 11:06:51',4,0,NULL,NULL,NULL,'9ffbb2d4-8048-48bd-b851-b82557ca72d6'),(369,'Clients switched to 2nd line 6mnths','Clients switched to 2nd line 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients switched to 2nd line 6mnths\n Clients switched to 2nd line 6mnths\n \n 2019-02-05 09:08:12 UTC\n \n 2019-02-05 09:09: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 369\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:08:12',4,'2019-02-05 11:09:28',4,0,NULL,NULL,NULL,'b4c517ae-ed0c-4bf3-9f3e-8d94304b8659'),(370,'Clients switched to 2nd line 12mnths','Clients switched to 2nd line 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients switched to 2nd line 12mnths\n Clients switched to 2nd line 12mnths\n \n 2019-02-05 09:10:26 UTC\n \n 2019-02-05 09:11: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 370\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:10:26',4,'2019-02-05 11:11:30',4,0,NULL,NULL,NULL,'74e22b7b-d25f-4b23-864e-afd719a2ebc6'),(371,'Clients with follow up CD4 6mnths','Clients with follow up CD4 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with follow up CD4 6mnths\n Clients with follow up CD4 6mnths\n \n 2019-02-05 09:12:07 UTC\n \n 2019-02-05 09: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 371\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:12:07',4,'2019-02-05 11:15:04',4,0,NULL,NULL,NULL,'7b66107d-e6fb-48a3-ad99-d6a81b1269d9'),(372,'Clients with follow up CD4 12mnths','Clients with follow up CD4 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with follow up CD4 12mnths\n Clients with follow up CD4 12mnths\n \n 2019-02-05 09:15:54 UTC\n \n 2019-02-05 09:17: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 372\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:15:54',4,'2019-02-05 11:17:58',4,0,NULL,NULL,NULL,'e1ae9120-353f-4c65-85b9-184be1542760'),(373,'Clients with follow up Viral Load 6mnths','Clients with follow up Viral Load 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with follow up Viral Load 6mnths\n Clients with follow up Viral Load 6mnths\n \n 2019-02-05 09:19:41 UTC\n \n 2019-02-05 09:21: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 373\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:19:41',4,'2019-02-05 11:21:35',4,0,NULL,NULL,NULL,'5aa44431-8661-4c1e-92fe-8c117831f418'),(374,'Clients with follow up Viral Load 12mnths','Clients with follow up Viral Load 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with follow up Viral Load 12mnths\n Clients with follow up Viral Load 12mnths\n \n 2019-02-05 09:22:53 UTC\n \n 2019-02-05 09:25: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 374\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:22:53',4,'2019-02-05 11:25:34',4,0,NULL,NULL,NULL,'eb510470-5a6d-45a4-bdeb-6d905570bd0d'),(375,'Clients lost to follow up 6mnths','Clients lost to follow up 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients lost to follow up 6mnths\n Clients lost to follow up 6mnths\n \n 2019-02-05 09:26:21 UTC\n \n 2019-02-05 09:28: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 375\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:26:21',4,'2019-02-05 11:28:11',4,0,NULL,NULL,NULL,'3efb72d7-384b-4492-8ef5-1e158fecae2a'),(376,'Clients lost to follow up 12mnths','Clients lost to follow up 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients lost to follow up 12mnths\n Clients lost to follow up 12mnths\n \n 2019-02-05 09:28:53 UTC\n \n 2019-02-05 09:31: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 376\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:28:53',4,'2019-02-05 11:31:22',4,0,NULL,NULL,NULL,'3e0765e1-b5cc-43ca-bc89-4585f5e9e7fb'),(377,'Clients dead 6mnths','Clients dead 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients dead 6mnths\n Clients dead 6mnths\n \n 2019-02-05 09:32:07 UTC\n \n 2019-02-05 09:33: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 377\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:32:07',4,'2019-02-05 11:33:08',4,0,NULL,NULL,NULL,'1f29b6b1-21b8-4931-9a38-a1cefbc302d3'),(378,'Clients dead 12 mnths','Clients dead 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients dead 12 mnths\n Clients dead 12mnths\n \n 2019-02-05 09:33:37 UTC\n \n 2019-02-05 09:34: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 378\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:33:37',4,'2019-02-05 11:34:30',4,0,NULL,NULL,NULL,'991435d7-ccd5-4e80-882f-bb8e3bf4f8b8'),(379,'Clients stopped 6mnths','Clients stopped 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients stopped 6mnths\n Clients stopped 6mnths\n \n 2019-02-05 09:35:01 UTC\n \n 2019-02-05 09:36: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 379\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:35:01',4,'2019-02-05 11:36:07',4,0,NULL,NULL,NULL,'c72f56a8-b67f-43ad-a2e4-a10be338e482'),(380,'Clients stopped 12 mnths','Clients stopped 12mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients stopped 12 mnths\n Clients stopped 12mnths\n \n 2019-02-05 09:36:39 UTC\n \n 2019-02-05 09:37: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 380\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-02-05 11:36:39',4,'2019-02-05 11:37:32',4,0,NULL,NULL,NULL,'8effc480-73a0-4806-9555-44ac56e09d6e'),(382,'Clients newly initiated 1c','1c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1c\n 1c\n \n 2019-02-06 15:02:44 UTC\n \n 2021-01-27 14:36: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 382\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2201 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:02:44',4,'2021-01-27 14:36:25',4,0,NULL,NULL,NULL,'eb143dfc-1a1c-4e1c-b2d9-243ca86dd111'),(383,'Clients newly initiated 1d ','1d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1d \n 1d\n \n 2019-02-06 15:13:24 UTC\n \n 2021-01-27 14:38: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 383\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2203 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:13:24',4,'2021-01-27 14:38:16',4,0,NULL,NULL,NULL,'3d4080ed-278a-4c48-a9a9-4d1c9359b3c5'),(384,'Clients newly initiated 1e','1e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1e\n 1e\n \n 2019-02-06 15:15:37 UTC\n \n 2021-01-27 14:39: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 384\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2205 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:15:37',4,'2021-01-27 14:39:22',4,0,NULL,NULL,NULL,'d1b27fb7-6798-4562-bbe2-7d2d71ccba59'),(385,'Clients newly initiated 1f','1f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1f\n 1f\n \n 2019-02-06 15:16:38 UTC\n \n 2021-01-27 14: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 385\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2207 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:16:38',4,'2021-01-27 14:39:57',4,0,NULL,NULL,NULL,'ce0026fa-a5a0-4729-9442-76d4e651f94a'),(386,'Clients newly initiated 1g ','1g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1g \n 1g\n \n 2019-02-06 15:18:38 UTC\n \n 2021-01-27 14:40: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 386\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3672 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:18:38',4,'2021-01-27 14:40:32',4,0,NULL,NULL,NULL,'05918dc5-51c4-4556-be64-efa548ddc957'),(387,'Clients newly initiated 1h','1h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1h\n 1h\n \n 2019-02-06 15:20:41 UTC\n \n 2021-01-27 14:41: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 387\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3673 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:20:41',4,'2021-01-27 14:41:11',4,0,NULL,NULL,NULL,'5147b850-5fee-42d3-b2bf-0c074c9eca96'),(388,'Clients newly initiated 2c','2c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2c\n 2c\n \n 2019-02-06 15:23:30 UTC\n \n 2021-01-27 14:52: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 388\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2210 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:23:30',4,'2021-01-27 14:52:56',4,0,NULL,NULL,NULL,'14d94e25-3c55-4434-b0ad-64e23f6a5404'),(389,'Clients newly initiated 2d','2d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2d\n 2d\n \n 2019-02-06 15:25:19 UTC\n \n 2021-01-27 14:53: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 389\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2209 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:25:19',4,'2021-01-27 14:53:48',4,0,NULL,NULL,NULL,'03f49548-9c17-4f5f-94d9-4e616d2758b8'),(390,'Clients newly initiated 2e','2e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2e\n 2e\n \n 2019-02-06 15:26:27 UTC\n \n 2021-01-27 14:54: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 390\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3674 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:26:27',4,'2021-01-27 14:54:34',4,0,NULL,NULL,NULL,'db68cb15-10f6-4f65-bee5-3c69d079c441'),(391,'Clients newly initiated 2f ','2f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2f \n 2f\n \n 2019-02-06 15:27:26 UTC\n \n 2021-01-27 14:55: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 391\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3675 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:27:26',4,'2021-01-27 14:55:21',4,0,NULL,NULL,NULL,'d3645a04-6157-4855-b645-d19c73b2827c'),(392,'Clients newly initiated 2g','2g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2g\n 2g\n \n 2019-02-06 15:28:29 UTC\n \n 2021-01-27 14:57: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 392\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3676 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:28:29',4,'2021-01-27 14:57:07',4,0,NULL,NULL,NULL,'0d4335ea-74f0-4cca-8ed7-ca4fa033880e'),(393,'Clients newly initiated 2h','2h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2h\n 2h\n \n 2019-02-06 15:29:20 UTC\n \n 2021-01-27 14:57: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 393\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3677 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-06 15:29:20',4,'2021-01-27 14:57:48',4,0,NULL,NULL,NULL,'4d44a02b-fe31-450d-887a-c5e769a13cb1'),(394,'Clients newly initiated 3a','3a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 3a\n 3a\n \n 2019-02-07 08:20:56 UTC\n \n 2021-01-27 15:12: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 394\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3683 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-07 08:20:56',4,'2021-01-27 15:12:32',4,0,NULL,NULL,NULL,'995ebf26-1945-4e6a-b041-c401c06d4b90'),(395,'Clients newly initiated 3b','3b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 3b\n 3b\n \n 2019-02-07 08:21:56 UTC\n \n 2021-01-27 15:14: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 395\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3684 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-07 08:21:56',4,'2021-01-27 15:14:28',4,0,NULL,NULL,NULL,'b447da00-0b30-4205-8027-ebe5951ed320'),(400,'Clients seen 4c','4c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 4c\n 4c\n \n 2019-02-07 10:22:40 UTC\n \n 2019-05-08 09:05: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 400\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2202 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-02-07 10:22:40',4,'2019-05-08 09:05:39',4,0,NULL,NULL,NULL,'568c8c09-01b5-4a1c-8892-f558350b2abf'),(401,'Clients seen 4d','4d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 4d\n 4d\n \n 2019-02-07 10:24:59 UTC\n \n 2019-05-08 09: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 401\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 2204 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date < :endDate \n and dead = 1 \n ) \n \n \n','2019-02-07 10:24:59',4,'2019-05-08 09:53:30',4,0,NULL,NULL,NULL,'df3b2c47-8c25-4a90-a9cf-4a98a52d87de'),(402,'Clients seen 4e','4e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 4e\n 4e\n \n 2019-02-07 10:28:19 UTC\n \n 2019-05-08 09:54: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 402\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3679 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-02-07 10:28:19',4,'2019-05-08 09:54:32',4,0,NULL,NULL,NULL,'37ad57a6-6821-4f3b-bc29-05ab90bc774a'),(403,'Clients seen 4f','4f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 4f\n 4f\n \n 2019-02-07 10:29:37 UTC\n \n 2019-05-08 09:55: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 403\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3680 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date < :endDate \n and dead = 1 \n ) \n \n \n','2019-02-07 10:29:37',4,'2019-05-08 09:55:25',4,0,NULL,NULL,NULL,'ad3ba0a3-3589-4b24-8645-ea12a81be5bf'),(404,'Clients seen 6a','6a RAL-EFV-LPV','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 6a\n 6a RAL-EFV-LPV\n \n 2019-02-07 10:39:49 UTC\n \n 2019-05-08 10:48: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 404\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3686 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-02-07 10:39:49',4,'2019-05-08 10:48:52',4,0,NULL,NULL,NULL,'a20a7a05-5360-43b9-b48e-81294d4f06e9'),(406,'Clients newly initiated 3c','3c as 6a under dhis2 adults 3rd line','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 3c\n 3c as 6a under dhis2 adults 3rd line\n \n 2019-02-07 11:02:00 UTC\n \n 2021-01-27 15:20: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 406\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3685 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2019-02-07 11:02:00',4,'2021-01-27 15:20:40',4,0,NULL,NULL,NULL,'354eee1a-35a6-473c-9029-4e4e66042646'),(407,'Clients seen 3c','3c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 3c\n 3c\n \n 2019-02-07 13:35:11 UTC\n \n 2019-05-08 10:38: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 407\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-02-07 13:35:11',4,'2019-05-08 10:38:50',4,0,NULL,NULL,NULL,'604a75e1-4aac-413b-be90-3c3f5f0e1506'),(408,'Clients multi month 3c','3c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients multi month 3c\n 3c\n \n 2019-02-07 13:57:32 UTC\n \n 2019-05-09 09:40: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 408\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176,4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177,4245,4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id \n AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONTHS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245, 4246 ,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246,4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n ) \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4175)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4176)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n ) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4177)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n ) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4245)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \nAND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n ) \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4246)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n ) \n \n ) \n \n \n \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded in (4247)) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location )) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location ) \n AND o.person_id in ( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3685 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n ) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 WHERE (o.location_id =:location or parent_location =:location )) \nand Id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0) \nAND Id not in ( \n \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate,interval 1 DAY) \n and dead = 1 \n ) \nAND Id not in( \n select distinct Id from \n (select distinct person_id as Id, max(value_datetime), datediff(CAST(:endDate AS DATE), max(value_datetime)) AS Num_Days \n FROM obs \n WHERE concept_id = 3752 \n group by person_id \n HAVING Num_Days >= 7) as finalised \n )\n','2019-02-07 13:57:32',4,'2019-05-09 09:40:39',4,0,NULL,NULL,NULL,'30fa519d-6d87-453f-a68f-fbfe97d650b9'),(409,'Clients seen given 1 month supply 4c','4c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4c\n 4c\n \n 2019-02-07 14:01:00 UTC\n \n 2021-02-04 07:31: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 409\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 2202) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 2202 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2019-02-07 14:01:00',4,'2021-02-04 07:31:35',4,0,NULL,NULL,NULL,'537bfeb1-7f85-4387-81c1-79f35d6b8193'),(410,'Clients seen given 1 month supply 4d','4d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4d\n 4d\n \n 2019-02-07 14:02:06 UTC\n \n 2021-02-04 07:32: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 410\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 2204) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 2204 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2019-02-07 14:02:06',4,'2021-02-04 07:32:24',4,0,NULL,NULL,NULL,'306b1f50-9652-42e5-9f9f-bacb1a1f3ed1'),(411,'Clients seen given 1 month supply 4e','4e ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4e\n 4e \n \n 2019-02-07 14:05:31 UTC\n \n 2021-02-04 07: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 411\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3679) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3679 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2019-02-07 14:05:31',4,'2021-02-04 07:35:39',4,0,NULL,NULL,NULL,'7bd605b0-4f07-4730-b79e-ea885c4dc22a'),(412,'Clients seen given 1 month supply 4f','4f ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4f\n 4f \n \n 2019-02-07 14:09:36 UTC\n \n 2021-02-04 07:36: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 412\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3680) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3680 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2019-02-07 14:09:36',4,'2021-02-04 07:36:27',4,0,NULL,NULL,NULL,'61c10574-82e0-409f-b573-2ed12e5234ef'),(413,'Clients seen given 1 month supply 5a','5a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 5a\n 5a\n \n 2019-02-07 14:14:11 UTC\n \n 2021-02-04 07:47: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 413\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3681) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3681 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2019-02-07 14:14:11',4,'2021-02-04 07:47:50',4,0,NULL,NULL,NULL,'35491dfa-1e7f-4a01-9c4c-3d741887d1fc'),(414,'Clients seen given 1 month supply 5b','5b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 5b\n 5b\n \n 2019-02-07 14:16:20 UTC\n \n 2021-02-04 07:55: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 414\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3682) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3682 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2019-02-07 14:16:20',4,'2021-02-04 07:55:49',4,0,NULL,NULL,NULL,'b828f7ad-12f5-42fa-9217-e1deb46fb67b'),(415,'Clients seen 5a','5a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 5a\n 5a\n \n 2019-02-07 14:18:43 UTC\n \n 2019-05-08 10:18: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 415\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3681 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-02-07 14:18:43',4,'2019-05-08 10:18:10',4,0,NULL,NULL,NULL,'79aeb902-4831-4559-9766-1fcfe976732d'),(416,'Clients seen 5b','5b 2 or 3mnths','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen 5b\n 5b 2 or 3mnths\n \n 2019-02-07 14:19:37 UTC\n \n 2019-05-08 10: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 416\n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND :endDate) \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 \nWHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in( \n select distinct person_id \n from obs \n -- All patients given 1F regimen during a particular period \n where concept_id = 2250 and value_coded = 3682 \n AND obs_datetime between :startDate AND :endDate \n) \nand patient.patient_id not in -- CLIENTS NEWLY INITIATED ON ART \n (select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN :startDate AND :endDate) \n AND patient.voided = 0 AND o.voided = 0 \n and patient.patient_id not in( \n select distinct os.person_id from obs os \n where os.concept_id = 2396 \n AND DATE(os.obs_datetime) BETWEEN :startDate AND :endDate) \n \n ) \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n and obs_datetime <= :endDate \n group by person_id) one, \n \n (select person_id,obs_datetime \n from obs \n where concept_id = 3843 \n and obs_datetime <= :endDate) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \n \nAND patient.patient_id not in \n ( \n select distinct person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n \n','2019-02-07 14:19:37',4,'2019-05-08 10:21:05',4,0,NULL,NULL,NULL,'08e17546-29ca-41a6-8457-faa0da7126d1'),(417,'CMP_ART Regimen 1month supply 5g','5g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 5g\n 5g\n \n 2019-02-07 14:22:10 UTC\n \n 2021-01-28 00:57: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 417\n Clients-newly-initiated-5g OR Clients-seen-given-1-month-supply-5g\n \n \n Clients-newly-initiated-5g\n \n \n \n \n endDate\n ${}\n \n \n location\n ${}\n \n \n startDate\n ${}\n \n \n \n \n \n Clients-seen-given-1-month-supply-5g\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','2019-02-07 14:22:10',4,'2021-01-28 00:57:28',4,0,NULL,NULL,NULL,'c90d4873-21fb-444f-94f3-0c29f7e1c723'),(418,'CMP_ART Regimen 1month supply 4c','4c ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4c\n 4c \n \n 2019-02-07 14:28:09 UTC\n \n 2021-01-27 23:38: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 418\n Clients-seen-given-1-month-supply-4c OR Clients-newly-initiated-4c\n \n \n Clients-seen-given-1-month-supply-4c\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 Clients-newly-initiated-4c\n \n \n \n \n \n \n','2019-02-07 14:28:09',4,'2021-01-27 23:38:54',4,0,NULL,NULL,NULL,'b734b3a4-c03d-4870-aee6-ae72d7cd09a3'),(419,'CMP_ART Regimen 1month supply 4d','4d ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4d\n 4d \n \n 2019-02-07 14:33:46 UTC\n \n 2021-01-27 23:48: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 419\n Clients-newly-initiated-4d OR Clients-seen-given-1-month-supply-4d\n \n \n Clients-newly-initiated-4d\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 Clients-seen-given-1-month-supply-4d\n \n \n \n \n \n \n','2019-02-07 14:33:46',4,'2021-01-27 23:48:30',4,0,NULL,NULL,NULL,'6fd05fe9-d0f9-4df1-af32-f779445dfa47'),(420,'CMP_ART Regimen 1month supply 4e','4e ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4e\n 4e \n \n 2019-02-07 14:48:47 UTC\n \n 2021-01-27 23:52: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 420\n Clients-newly-initiated-4e OR Clients-seen-given-1-month-supply-4e\n \n \n Clients-newly-initiated-4e\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 Clients-seen-given-1-month-supply-4e\n \n \n \n \n \n \n','2019-02-07 14:48:47',4,'2021-01-27 23:52:23',4,0,NULL,NULL,NULL,'4c813098-94b5-4e1d-8e8a-baeccd78bad2'),(421,'CMP_ART Regimen 1month supply 4f','4f ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4f\n 4f \n \n 2019-02-07 14:53:34 UTC\n \n 2021-01-27 23:55: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 421\n Clients-newly-initiated-4f OR Clients-seen-given-1-month-supply-4f\n \n \n Clients-newly-initiated-4f\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 Clients-seen-given-1-month-supply-4f\n \n \n \n \n \n \n','2019-02-07 14:53:34',4,'2021-01-27 23:55:36',4,0,NULL,NULL,NULL,'33d92626-132a-476e-8c20-0738c0517731'),(424,'CMP_ART Regimen 1month supply 5a','5a ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 5a\n 5a \n \n 2019-02-07 15:09:01 UTC\n \n 2021-01-28 00:23: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 424\n Clients-seen-given-1-month-supply-5a OR Clients-newly-initiated-5a\n \n \n Clients-seen-given-1-month-supply-5a\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 Clients-newly-initiated-5a\n \n \n \n \n \n \n','2019-02-07 15:09:01',4,'2021-01-28 00:23:10',4,0,NULL,NULL,NULL,'e5755cdd-222c-4005-b535-2b7b2027a776'),(425,'Clients given 5a current and multi month','5a 1-3mnths','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5a current and multi month\n 5a 1-3mnths\n \n 2019-02-07 15:16:38 UTC\n \n 2019-02-07 15:17: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 425\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.concept_id = 2250 \nand o.value_coded = 3681 \nand o.voided = 0 \nand obs_datetime between :startDate and :endDate;\n','2019-02-07 15:16:38',4,'2019-02-07 15:17:59',4,0,NULL,NULL,NULL,'f69352a8-954a-409e-9bcc-72c382522568'),(426,'CMP_ART Regimen 1month supply 5b','5b ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 5b\n 5b \n \n 2019-02-07 15:20:08 UTC\n \n 2021-01-28 00:28: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 426\n Clients-seen-given-1-month-supply-5b OR Clients-newly-initiated-5b\n \n \n Clients-seen-given-1-month-supply-5b\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 Clients-newly-initiated-5b\n \n \n \n \n \n \n','2019-02-07 15:20:08',4,'2021-01-28 00:28:10',4,0,NULL,NULL,NULL,'776337cf-5614-4b95-9c43-b322b1a2bd3b'),(427,'CMP_ART Regimen 1month supply 6a','6a ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 6a\n 6a \n \n 2019-02-07 15:24:04 UTC\n \n 2021-01-28 01:16: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 427\n Clients-seen-given-1-month-supply-6a OR Clients-newly-initiated-6a\n \n \n Clients-seen-given-1-month-supply-6a\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 Clients-newly-initiated-6a\n \n \n \n \n \n \n','2019-02-07 15:24:04',4,'2021-01-28 01:16:54',4,0,NULL,NULL,NULL,'dba3de7f-67e9-4b23-b63e-7c58c308165d'),(428,'Clients seen given 1 month supply 6a','6a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 6a\n 6a\n \n 2019-02-07 15:28:03 UTC\n \n 2021-02-04 08:14: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 428\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3686) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3686 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2019-02-07 15:28:03',4,'2021-02-04 08:14:10',4,0,NULL,NULL,NULL,'53316cf7-0a79-49e4-9dd4-5f00f847b3b1'),(429,'TESTING','ALL TESTS','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TESTING\n ALL TESTS\n \n 2019-02-12 09:23:54 UTC\n \n 2019-02-19 10:51: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 429\n select distinct person_id \nfrom obs \nwhere concept_id = 3843 \nand value_coded in (3841) \nAND (DATE(obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1)); \n \n\n','2019-02-12 09:23:54',4,'2019-02-19 10:51:01',4,0,NULL,NULL,NULL,'0e162295-6055-46ea-8c17-5fca300d0054'),(430,'testing','n/a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n testing\n n/a\n \n 2019-02-13 14:14:05 UTC\n \n 2020-07-06 07:28: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 430\n (select o.person_id,CAST(value_datetime AS DATE) as blood_drawn \nfrom obs o \ninner join \n (select person_id,max(obs_datetime) maxdate \n from obs a \n where obs_datetime <= :endDate \n and concept_id = 4267 \n group by person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 4267 \n and o.obs_datetime = maxdate \n )\n','2019-02-13 14:14:05',4,'2020-07-06 07:28:05',4,0,NULL,NULL,NULL,'dd019ae7-3549-4fd7-b3ee-b7ac841707f2'),(431,'lets see','N/A','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n lets see\n N/A\n \n 2019-02-15 10:05:49 UTC\n \n 2019-02-15 12:46: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 431\n SELECT DISTINCT Id \nFROM \n \n( \nselect distinct patient.patient_id AS Id \n \n from obs o \n \n \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD('2019-01-31', INTERVAL -1 MONTH)) \n and YEAR(o.obs_datetime) = YEAR(DATE_ADD('2019-01-31', INTERVAL -1 MONTH)) \n AND patient.voided = 0 \n AND o.voided = 0 \n AND (o.concept_id = 4174 and (o.value_coded in (4176,4177,4245,4246,4247))) \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 \n AND patient_identifier.identifier_type = 3 \n \n \n \nUNION \n \nselect distinct patient.patient_id AS Id \n \n from obs o \n \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD('2019-01-31', INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD('2019-01-31', INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4175 \n AND o.person_id in ( \n select distinct os.person_id from obs os \n \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD('2019-01-31', INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD('2019-01-31', INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 \n AND DATEDIFF(os.value_datetime, '2019-01-31') BETWEEN 0 AND 28 \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 \n \n \n \n) AS ARTCurrent_PrevMonths \n \nWHERE Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n \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 (DATE(o.obs_datetime) BETWEEN '2019-01-01' AND addDate('2019-01-31', 1)) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id \n AND patient_identifier.identifier_type = 3 \nWHERE patient.patient_id not in ( \n select distinct patient.patient_id AS Id \n from obs o \n -- CLIENTS NEWLY INITIATED ON ART \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND (o.concept_id = 2249 AND DATE(o.value_datetime) BETWEEN '2019-01-01' AND addDate('2019-01-31', 1)) \nAND patient.voided = 0 AND o.voided = 0 \n \nAND 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 DATE(os.obs_datetime) BETWEEN '2019-01-01' AND addDate('2019-01-31', 1) \n \n ) \n ))\n','2019-02-15 10:05:49',4,'2019-02-15 12:46:15',4,0,NULL,NULL,NULL,'82d59123-ac4a-4c14-8218-0738d4ade605'),(432,'Clients given 4mnths 1f in previous 3mnths','1f 4mnths ago','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4mnths 1f in previous 3mnths\n 1f 4mnths ago\n \n 2019-02-19 09:39:58 UTC\n \n 2019-02-19 09:58: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 432\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.concept_id = 4174 and o.value_coded in (4245,4246) \n \nand o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 2250 \n and os.value_coded = 2207 \n and MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n and YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n) \n \nand MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \nand YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \nand o.voided = 0\n','2019-02-19 09:39:58',4,'2019-02-19 09:58:09',4,0,NULL,NULL,NULL,'c2adcb8a-c735-4860-a9d8-9509ac29d363'),(433,'Clients given 5mnths 1f in previous m4nths','1f 5mnths ago','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5mnths 1f in previous m4nths\n 1f 5mnths ago\n \n 2019-02-19 09:59:13 UTC\n \n 2019-02-19 10:02: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 433\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.concept_id = 4174 and o.value_coded in (4246) \n \nand o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 2250 \n and os.value_coded = 2207 \n and MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n and YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n) \n \nand MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \nand YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \nand o.voided = 0\n','2019-02-19 09:59:13',4,'2019-02-19 10:02:40',4,0,NULL,NULL,NULL,'809ab22c-a795-46ba-b8af-1a21a51551e4'),(435,'Master HIVTC 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 Master HIVTC report Data Set\n \n 2019-02-21 14:56:31 UTC\n \n 2019-03-01 10:34: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 435\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n \n \n DM_Weight_Updated\n \n \n \n \n \n \n \n \n 1ST4c3.9F\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 Children 0to14\n \n \n DM_Weight_Updated\n 03to3.9kg\n \n \n \n \n \n 1st4c3.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 03to3.9kg\n \n \n \n \n \n 1st4c5.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 04to5.9kg\n \n \n \n \n \n 1st4c5.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 04to5.9kg\n \n \n \n \n \n 1st4d13.9F\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 10to13.9kg\n \n \n \n \n \n 1st4d13.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 10to13.9kg\n \n \n \n \n \n 1st4d19.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 14to19.9kg\n \n \n \n \n \n 1st4d19.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 14to19.9kg\n \n \n \n \n \n 1st4d24.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 20to24.9kg\n \n \n \n \n \n 1st4d24.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 20to24.9kg\n \n \n \n \n \n 1st4d25F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 25+kg\n \n \n \n \n \n 1st4d25M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 25+kg\n \n \n \n \n \n 1st4d3.9F\n \n \n \n \n \n \n 1st4d3.9M\n \n \n \n \n \n \n 1st4d5.9F\n \n \n \n \n \n \n 1st4d5.9M\n \n \n \n \n \n \n 1st4d9.9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 06to9.9kg\n \n \n \n \n \n 1st4d9.9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n DM_Weight_Updated\n 06to9.9kg\n \n \n \n \n \n 1stlineCF\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Adults\n \n \n \n \n \n 1stlineCM\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Adults\n \n \n \n \n \n 1stlineDF\n \n \n \n \n \n \n \n \n \n 1stlineDM\n \n \n \n \n \n \n 1stlineEF\n \n \n \n \n \n \n \n \n \n 1stlineEM\n \n \n \n \n \n \n 1stlineFF\n \n \n \n \n \n \n \n \n \n 1stlineFM\n \n \n \n \n \n \n 1stlineGF\n \n \n \n \n \n \n \n \n \n 1stlineGM\n \n \n \n \n \n \n 1stlineHF\n \n \n \n \n \n \n \n \n \n 1stlineHM\n \n \n \n \n \n \n','2019-02-21 14:56:31',4,'2019-03-01 10:34:21',4,0,NULL,NULL,NULL,'41857c4c-d7eb-4ab2-8266-3bb1cdb084f0'),(436,'clients seen 2months ago','2mnths+','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients seen 2months ago\n 2mnths+\n \n 2019-02-27 10:29:03 UTC\n \n 2019-02-27 10:29: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 436\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n and YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and (o.value_coded = 4176 or o.value_coded = 4177 or o.value_coded = 4245 or o.value_coded = 4246 or o.value_coded = 4247)) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id \n AND patient_identifier.identifier_type = 3 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4175 \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4176 \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \n \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id \n AND patient_identifier.identifier_type = 3 \nand patient.patient_id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 DATE(os.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1) \n \n ) \n ) \n WHERE (o.location_id =:location or parent_location =:location) \n)\n','2019-02-27 10:29:03',4,'2019-02-27 10:29:19',4,0,NULL,NULL,NULL,'a5bf5837-dafc-404e-9eb8-77501187ac6f'),(437,'clients seen 3months ago','3mnths+','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients seen 3months ago\n 3mnths+\n \n 2019-02-27 10:30:44 UTC\n \n 2019-02-27 10:34: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 437\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 2 MONTHS AND WAS GIVEN (3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -2 MONTH)) \n AND patient.voided = 0 \n AND o.voided = 0 \n AND o.concept_id = 4174 \n and (o.value_coded = 4177 or o.value_coded = 4245 or o.value_coded = 4246 or o.value_coded = 4247) \n INNER JOIN person ON person.person_id = patient.patient_id \n 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 \n AND patient_identifier.identifier_type = 3 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \n \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4177 \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id \n AND patient_identifier.identifier_type = 3 \nand patient.patient_id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 DATE(os.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1) \n \n ) \n ) \n WHERE (o.location_id =:location or parent_location =:location) \n)\n','2019-02-27 10:30:44',4,'2019-02-27 10:34:49',4,0,NULL,NULL,NULL,'21c776ca-7cbc-4388-a623-06e351469a20'),(438,'clients seen 4months ago','4mnths+','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients seen 4months ago\n 4mnths+\n \n 2019-02-27 10:37:22 UTC\n \n 2019-02-27 10:37: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 438\n SELECT DISTINCT Id \nFROM \n( \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 3 MONTHS AND WAS GIVEN (4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -3 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and (o.value_coded = 4245 or o.value_coded = 4246 or o.value_coded = 4247) \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 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4245 \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id \n AND patient_identifier.identifier_type = 3 \nand patient.patient_id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 DATE(os.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1) \n \n ) \n ) \n WHERE (o.location_id =:location or parent_location =:location) \n)\n','2019-02-27 10:37:22',4,'2019-02-27 10:37:36',4,0,NULL,NULL,NULL,'41a0d5e0-f46f-4cd7-a361-ea6ea3b5933e'),(439,'clients seen 5mnths ago','5mnths +','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients seen 5mnths ago\n 5mnths +\n \n 2019-02-27 10:45:50 UTC\n \n 2019-02-27 10:47: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 439\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 4 MONTHS AND WAS GIVEN (5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -4 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and (o.value_coded = 4246 or o.value_coded = 4247) \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 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4246 \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 \n WHERE (o.location_id =:location or parent_location =:location) \n \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id \n AND patient_identifier.identifier_type = 3 \nand patient.patient_id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 DATE(os.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1) \n \n ) \n ) \n WHERE (o.location_id =:location or parent_location =:location) \n)\n','2019-02-27 10:45:50',4,'2019-02-27 10:47:06',4,0,NULL,NULL,NULL,'7cef2932-533c-42ca-96fa-90f10ea3badb'),(440,'clients seen 6months ago','6mnths +','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients seen 6months ago\n 6mnths +\n \n 2019-02-27 10:49:11 UTC\n \n 2019-02-27 10:50: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 440\n SELECT DISTINCT Id \nFROM \n( \n \n(select distinct patient.patient_id AS Id \n \n from obs o \n -- CAME IN PREVIOUS 5 MONTHS AND WAS GIVEN (6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -5 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \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 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \nUNION \n \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 4174 and o.value_coded = 4247 \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id =:location or parent_location =:location)) \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 \n WHERE (o.location_id =:location or parent_location =:location) \n ) \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.Id not in ( \n select distinct patient.patient_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n INNER JOIN location l on o.location_id = l.location_id \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 (DATE(o.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id \n AND patient_identifier.identifier_type = 3 \nand patient.patient_id not in ( \n select distinct patient.patient_id AS Id \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 AND DATE(o.value_datetime) BETWEEN :startDate AND addDate(:endDate, 1)) \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 DATE(os.obs_datetime) BETWEEN :startDate AND addDate(:endDate, 1) \n \n ) \n ) \n WHERE (o.location_id =:location or parent_location =:location) \n)\n','2019-02-27 10:49:11',4,'2019-02-27 10:50:14',4,0,NULL,NULL,NULL,'5f4b2a04-8b0c-4add-b7c9-7b70515f603d'),(441,'clients seen 2 to 6mnths ago','composition','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients seen 2 to 6mnths ago\n composition\n \n 2019-02-27 10:59:28 UTC\n \n 2019-02-27 14:18: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 441\n clients-seen-3months-ago OR clients-seen-2months-ago\n \n \n clients-seen-3months-ago\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','2019-02-27 10:59:28',4,'2019-02-27 14:18:26',4,0,NULL,NULL,NULL,'8f521b14-95ad-4e4c-b03d-10c0b7b3a0aa'),(442,'Clients on ARV who died','Clients on ARV who died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients on ARV who died\n Clients on ARV who died\n \n 2019-03-29 06:48:55 UTC\n \n 2022-04-28 08:21: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 442\n select person_id \n from person \n where death_date <= CAST(:endDate AS DATE) \n AND MONTH(death_date) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(death_date) = YEAR(CAST(:endDate AS DATE)) \n and dead = 1\n','2019-03-29 06:48:55',4,'2022-04-28 08:21:40',4,0,NULL,NULL,NULL,'914d4f42-66e2-4fce-b1da-d3fce7f95f15'),(443,'Clients given 2weeks ARV','Clients given 2weeks ARV','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 2weeks ARV\n Clients given 2weeks ARV\n \n 2019-03-29 07:53:59 UTC\n \n 2019-03-29 07: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 443\n select distinct Id from( \nselect distinct Id from \n( \n (select distinct o.person_id AS 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 = 2250 \n and o.value_coded in (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n and o.person_id in ( \n select distinct o.person_id \n from obs o \n where (o.concept_id = 4174 and o.value_coded = 4243) \n and obs_datetime BETWEEN :startDate and DATE_ADD(:endDate, INTERVAL 1 DAY) \n ) \n \n and o.voided = 0 \n and obs_datetime BETWEEN :startDate and DATE_ADD(:endDate, INTERVAL 1 DAY) \n ) \n UNION \n(select distinct patient.patient_id AS Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN location l on o.location_id = l.location_id \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -28 DAY)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -28 DAY)) \n AND patient.voided = 0 AND o.voided = 0 \n AND (o.concept_id = 4174 and o.value_coded = 4243) \n AND o.person_id in ( \n select distinct os.person_id from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n INNER JOIN location l on os.location_id = l.location_id \n where MONTH(os.obs_datetime) = MONTH(DATE_ADD(:endDate, INTERVAL -28 DAY)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(:endDate, INTERVAL -28 DAY)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, :endDate) BETWEEN 0 AND 28 \n AND (os.location_id = :location or parent_location = :location ) \n ) \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n WHERE (o.location_id = :location or parent_location = :location ) \n and o.person_id in( \n select distinct person_id from obs os \n where os.concept_id = 2250 \n and os.value_coded in (2201,2203,2205,2207,3672,3673,2210,2209,3674,3675,3676,3677,3683,3684,3685,2202,2204,3679,3680,3681,3682,3686,2143) \n ) \n ) \n) as regimen \nwhere Id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < DATE_ADD(:endDate, INTERVAL 1 DAY)) \n ) \nAND Id not in ( \n select person_id \n from person \n where death_date < DATE_ADD(:endDate, INTERVAL 1 DAY) \n and dead = 1 \n ) \n )as final\n','2019-03-29 07:53:59',4,'2019-03-29 07:57:45',4,0,NULL,NULL,NULL,'d8bb0175-47c0-461b-b457-498c8ef3cf27'),(445,'Total 1F Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Total 1F Data Set\n \n 2019-04-24 08:11:13 UTC\n \n 2019-04-24 08:14: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 445\n \n \n DM_Sex\n \n \n \n \n \n \n \n \n 1Line1fF\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 1stLine1FM\n \n \n \n \n DM_Sex\n Males\n \n \n \n \n \n','2019-04-24 08:11:13',4,'2019-04-24 08:14:21',4,0,NULL,NULL,NULL,'9169293f-f54e-4905-a477-15f43395d28a'),(446,'SQL Version Total Clients Registered for ART','SQL Version Total Clients Registered for ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n SQL Version Total Clients Registered for ART\n SQL Version Total Clients Registered for ART\n \n 2019-07-10 12:51:51 UTC\n \n 2023-10-17 14:02:12 UTC\n \n \n location\n \n org.openmrs.Location\n true\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 446\n SELECT distinct p.person_id AS Id \n FROM person p \n INNER JOIN obs o ON o.person_id = p.person_id \n AND o.voided = 0 \n AND o.person_id in \n (select person_id from obs where concept_id = 2403 and voided = 0) \n AND o.person_id not in \n (select person_id from obs where concept_id = 5416 and value_coded = 1 and voided = 0) \n INNER JOIN person_name pn ON p.person_id = pn.person_id \n INNER JOIN patient_identifier pi1 ON pi1.patient_id = p.person_id AND pi1.voided = 0 and pi1.preferred = 1 \n AND pi1.identifier_type = 3 \n LEFT JOIN patient_identifier pi2 ON pi2.patient_id = p.person_id AND pi2.identifier_type in (5,12) \n JOIN location l on o.location_id = l.location_id and l.retired=0 \n WHERE p.voided = 0 \n \nUNION \n \n SELECT distinct o.person_id AS Id \n FROM obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN patient_identifier p ON o.person_id = p.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 \n JOIN location l on o.location_id = l.location_id and l.retired=0 \n WHERE p.identifier_type in (5,12) \n AND o.voided = 0 \n AND o.person_id not in (select person_id from obs where concept_id = 2403 and voided = 0) \n group by patient_identifier.identifier\n','2019-07-10 18:21:51',4,'2023-10-17 19:32:12',4,0,NULL,NULL,NULL,'dabb33fe-f6f9-479c-82a0-d93c5a681b36'),(447,'SQL Version Total Registered ART Client with Intakes captured','SQL Version Total Registered ART Client with Intakes captured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n SQL Version Total Registered ART Client with Intakes captured\n SQL Version Total Registered ART Client with Intakes captured\n \n 2019-07-11 01:08:18 UTC\n \n 2023-10-17 14: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 447\n SELECT distinct p.person_id AS Id \n FROM person p \n INNER JOIN obs o ON o.person_id = p.person_id \n AND o.voided = 0 \n AND o.person_id in \n (select person_id from obs where concept_id = 2249 and voided = 0) \n AND o.person_id not in \n (select person_id from obs where concept_id = 5416 and value_coded = 1 and voided = 0) \n INNER JOIN person_name pn ON p.person_id = pn.person_id \n INNER JOIN patient_identifier pi1 ON pi1.patient_id = p.person_id AND pi1.voided = 0 and pi1.preferred = 1 \n AND pi1.identifier_type = 3 \n LEFT JOIN patient_identifier pi2 ON pi2.patient_id = p.person_id AND pi2.identifier_type in (5,12) \n JOIN location l on o.location_id = l.location_id and l.retired=0 \n WHERE p.voided = 0 \n AND concept_id = 2403 \n \nUNION \n \n SELECT distinct o.person_id AS Id \n FROM obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN patient_identifier p ON o.person_id = p.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 \n JOIN location l on o.location_id = l.location_id and l.retired=0 \n WHERE p.identifier_type in (5,12) \n AND o.voided = 0 \n AND o.person_id not in (select person_id from obs where concept_id = 2403 and voided = 0) \n AND concept_id = 2249 \n group by patient_identifier.identifier\n','2019-07-11 06:38:18',4,'2023-10-17 19:51:57',4,0,NULL,NULL,NULL,'f7926250-cdd1-4446-9106-bfe81ce908f5'),(448,'CI36: Total Registered ART Clients','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI36: Total Registered ART Clients\n \n \n 2019-07-11 01:17:50 UTC\n \n 2019-07-11 01:21: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 448\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-07-11 03:17:50',4,'2019-07-11 03:21:53',4,0,NULL,NULL,NULL,'860c7123-a8a4-46d1-8c5e-2c33ac1a2632'),(449,'CI37: Total Registered ART Clients with Intakes Captured','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI37: Total Registered ART Clients with Intakes Captured\n \n \n 2019-07-11 01:19:42 UTC\n \n 2019-07-11 01:22: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 449\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-07-11 03:19:42',4,'2019-07-11 03:22:26',4,0,NULL,NULL,NULL,'817d04b5-b407-4ede-a59a-8eac041616cd'),(450,'PIR13: Registered ART Clients with Intakes Progress Report','Period Indicator report for all ART client registered who have their intake form captured in eRegister','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR13: Registered ART Clients with Intakes Progress Report\n Period Indicator report for all ART client registered who have their intake form captured in eRegister\n \n 2019-07-11 01:24:13 UTC\n \n 2019-07-11 02: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 450\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','2019-07-11 03:24:13',4,'2019-07-11 04:03:08',4,0,NULL,NULL,NULL,'987a79c2-7ba9-47ff-8623-984851a6ae0e'),(451,'Total Registered ART Clients with Intakes Progress 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 Total Registered ART Clients with Intakes Progress Report Data Set\n \n 2019-07-11 01:24:17 UTC\n \n 2019-07-11 01: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 451\n \n \n \n IntakesReg\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 Registered\n \n \n \n \n \n \n \n \n \n','2019-07-11 03:24:17',4,'2019-07-11 03:26:20',4,0,NULL,NULL,NULL,'78f64364-5e5a-4ddd-aba9-b27bda9fe14d'),(452,'SQL Version Total ART Clients with Registered Visits','SQL Version Total ART Clients with Registered Visits','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n SQL Version Total ART Clients with Registered Visits\n SQL Version Total ART Clients with Registered Visits\n \n 2019-07-14 09:03:29 UTC\n \n 2019-07-14 09:37: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 452\n SELECT DISTINCT p.person_id \nFROM visit v \n JOIN person p on p.person_id = v.patient_id \n JOIN patient_identifier pi on v.patient_id = pi.patient_id and pi.identifier_type=5 \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type = 2 \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 and (l.location_id=:location or l.parent_location =:location) \nWHERE en.encounter_datetime >= :startDate and en.encounter_datetime <= :endDate \n \n\n','2019-07-14 11:03:29',4,'2019-07-14 11:37:46',4,0,NULL,NULL,NULL,'0181b364-876e-4307-bd8c-e986ea00f614'),(453,'SQL Version Clients with Visits with Consultations','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n SQL Version Clients with Visits with Consultations\n \n \n 2019-07-14 09:14:07 UTC\n \n 2019-07-14 09:18: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 453\n SELECT DISTINCT p.person_id as id \nFROM visit v \n JOIN person p on p.person_id = v.patient_id \n JOIN patient_identifier pi on v.patient_id = pi.patient_id and pi.identifier_type=5 \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type = 1 \n JOIN obs o on o.encounter_id=en.encounter_id and o.concept_id=3843 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n and (l.location_id=:location or l.parent_location =:location) \nWHERE en.encounter_datetime >= :startDate and en.encounter_datetime <= :endDate \n \n\n','2019-07-14 11:14:07',4,'2019-07-14 11:18:02',4,0,NULL,NULL,NULL,'08bfa6d5-d894-4fc1-8bb2-2db094829434'),(454,'CI38: Total ART Clients with Visits','Total ART Clients with Visits','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI38: Total ART Clients with Visits\n Total ART Clients with Visits\n \n 2019-07-14 09:25:12 UTC\n \n 2019-07-14 09:25: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 454\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-07-14 11:25:12',4,'2019-07-14 11:25:52',4,0,NULL,NULL,NULL,'9250be3a-1ae9-421e-9504-2bd10456a657'),(455,'CI39: Visiting ART Clients with Consultations','Visiting ART Clients with Consultations','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI39: Visiting ART Clients with Consultations\n Visiting ART Clients with Consultations\n \n 2019-07-14 09:26:59 UTC\n \n 2019-07-14 09:27: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 455\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2019-07-14 11:26:59',4,'2019-07-14 11:27:44',4,0,NULL,NULL,NULL,'4eccec5c-c7a8-436e-acec-88ed04f477cc'),(456,'PIR14: Total ART Clients with Consultations Process Report','Total ART Clients with Consultations Process Report','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR14: Total ART Clients with Consultations Process Report\n Total ART Clients with Consultations Process Report\n \n 2019-07-14 09:29:43 UTC\n \n 2019-07-14 09:29: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 456\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','2019-07-14 11:29:43',4,'2019-07-14 11:29:46',4,0,NULL,NULL,NULL,'d45c4571-c987-4271-8012-ad3e6e693d3d'),(457,'PIR14: Total ART Clients with Consultations Process 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 PIR14: Total ART Clients with Consultations Process Report Data Set\n \n 2019-07-14 09:29:46 UTC\n \n 2021-12-16 12:12: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 457\n \n \n \n ARTConsult\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 ARTVisits\n \n \n \n \n \n \n \n \n \n Pending1mn\n \n \n \n \n \n \n \n \n \n Pending2mn\n \n \n \n \n \n \n \n \n \n Pending3mn\n \n \n \n \n \n \n \n \n \n TPTComplet\n \n \n \n \n \n \n \n \n \n TPTContinu\n \n \n \n \n \n \n \n \n \n TPTStarted\n \n \n \n \n \n \n \n \n \n VLDraws3mn\n \n \n \n \n \n \n \n \n \n VLResul3mn\n \n \n \n \n \n \n \n \n \n VLResults\n \n \n \n \n \n \n \n \n \n','2019-07-14 11:29:46',4,'2021-12-16 14:12:13',4,0,NULL,NULL,NULL,'80c015cc-fa7f-4423-ad3f-07e7838ed1cb'),(458,'PITC','PITC section of HTS form','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC\n PITC section of HTS form\n \n 2020-04-24 12:00:15 UTC\n \n 2020-04-24 12:00: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 458\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','2020-04-24 12:00:15',4,'2020-04-24 12:00:18',4,0,NULL,NULL,NULL,'6bca981c-5d78-4a63-84e4-9185ea3356e9'),(459,'PITC Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC Data Set\n \n 2020-04-24 12:00:18 UTC\n \n 2020-05-11 07:42: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 459\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 PInewNe14F\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 10to14yrs\n \n \n \n \n \n PInewNe14M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n PInewNe19F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n PInewNe19M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n PInewNe24F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n PInewNe24M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n PInewNe29F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 25to29yrs\n \n \n \n \n \n PInewNe29M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 25to29yrs\n \n \n \n \n \n PInewNe34F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 30to34yrs\n \n \n \n \n \n PInewNe34M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 30to34yrs\n \n \n \n \n \n PInewNe39F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 35to39yrs\n \n \n \n \n \n PInewNe39M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 35to39yrs\n \n \n \n \n \n PInewNe44F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 40to44yrs\n \n \n \n \n \n PInewNe44M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 40to44yrs\n \n \n \n \n \n PInewNe49F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 45to49yrs\n \n \n \n \n \n PInewNe49M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 45to49yrs\n \n \n \n \n \n PInewNe50F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 50to100yrs\n \n \n \n \n \n PInewNe50M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 50to100yrs\n \n \n \n \n \n PInewNeg1F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n PInewNeg1M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n PInewNeg4F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n PInewNeg4M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n PInewNeg9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n PInewNeg9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n PInewPo14F\n \n \n \n \n \n \n \n \n \n PInewPo14M\n \n \n \n \n \n \n PInewPo19F\n \n \n \n \n \n \n PInewPo19M\n \n \n \n \n \n \n PInewPo24F\n \n \n \n \n \n \n PInewPo24M\n \n \n \n \n \n \n PInewPo29F\n \n \n \n \n \n \n PInewPo29M\n \n \n \n \n \n \n PInewPo34F\n \n \n \n \n \n \n PInewPo34M\n \n \n \n \n \n \n PInewPo39F\n \n \n \n \n \n \n PInewPo39M\n \n \n \n \n \n \n PInewPo44F\n \n \n \n \n \n \n PInewPo44M\n \n \n \n \n \n \n PInewPo49F\n \n \n \n \n \n \n PInewPo49M\n \n \n \n \n \n \n PInewPo50F\n \n \n \n \n \n \n PInewPo50M\n \n \n \n \n \n \n PInewPos1F\n \n \n \n \n \n \n PInewPos1M\n \n \n \n \n \n \n PInewPos4F\n \n \n \n \n \n \n PInewPos4M\n \n \n \n \n \n \n PInewPos9F\n \n \n \n \n \n \n PInewPos9M\n \n \n \n \n \n \n PIrepNe14F\n \n \n \n \n \n \n \n \n \n PIrepNe14M\n \n \n \n \n \n \n PIrepNe19F\n \n \n \n \n \n \n PIrepNe19M\n \n \n \n \n \n \n PIrepNe24F\n \n \n \n \n \n \n PIrepNe24M\n \n \n \n \n \n \n PIrepNe29F\n \n \n \n \n \n \n PIrepNe29M\n \n \n \n \n \n \n PIrepNe34F\n \n \n \n \n \n \n PIrepNe34M\n \n \n \n \n \n \n PIrepNe39F\n \n \n \n \n \n \n PIrepNe39M\n \n \n \n \n \n \n PIrepNe44F\n \n \n \n \n \n \n PIrepNe44M\n \n \n \n \n \n \n PIrepNe49F\n \n \n \n \n \n \n PIrepNe49M\n \n \n \n \n \n \n PIrepNe50F\n \n \n \n \n \n \n PIrepNe50M\n \n \n \n \n \n \n PIrepNeg1F\n \n \n \n \n \n \n PIrepNeg1M\n \n \n \n \n \n \n PIrepNeg4F\n \n \n \n \n \n \n PIrepNeg4M\n \n \n \n \n \n \n PIrepNeg9F\n \n \n \n \n \n \n PIrepNeg9M\n \n \n \n \n \n \n PIrepPo14F\n \n \n \n \n \n \n \n \n \n PIrepPo14M\n \n \n \n \n \n \n PIrepPo19F\n \n \n \n \n \n \n PIrepPo19M\n \n \n \n \n \n \n PIrepPo24F\n \n \n \n \n \n \n PIrepPo24M\n \n \n \n \n \n \n PIrepPo29F\n \n \n \n \n \n \n PIrepPo29M\n \n \n \n \n \n \n PIrepPo34F\n \n \n \n \n \n \n PIrepPo34M\n \n \n \n \n \n \n PIrepPo39F\n \n \n \n \n \n \n PIrepPo39M\n \n \n \n \n \n \n PIrepPo44F\n \n \n \n \n \n \n PIrepPo44M\n \n \n \n \n \n \n PIrepPo49F\n \n \n \n \n \n \n PIrepPo49M\n \n \n \n \n \n \n PIrepPo50F\n \n \n \n \n \n \n PIrepPo50M\n \n \n \n \n \n \n PIrepPos1F\n \n \n \n \n \n \n PIrepPos1M\n \n \n \n \n \n \n PIrepPos4F\n \n \n \n \n \n \n PIrepPos4M\n \n \n \n \n \n \n PIrepPos9F\n \n \n \n \n \n \n PIrepPos9M\n \n \n \n \n \n \n','2020-04-24 12:00:18',4,'2020-05-11 07:42:03',4,0,NULL,NULL,NULL,'d6f4d251-130b-4380-aba8-ddfeae303d42'),(460,'PITC_New_Negative','PITC_New_Negative clients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative\n PITC_New_Negative clients\n \n 2020-04-24 12:18:19 UTC\n \n 2021-07-22 18:12: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 460\n select distinct patient.patient_id AS Id \n \nfrom obs o \n-- HTS CLIENTS WITH NEGATIVE HIV STATUS BY SEX AND AGE \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND o.concept_id = 2165 and o.value_coded = 1016 \nAND patient.voided = 0 AND o.voided = 0 \nAND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n-- PROVIDER INITIATED TESTING AND COUNSELING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 4228 and os.value_coded = 4227 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \n-- NEW TESTER, DOES NOT HAVE A HISTORY OF PREVIOUS TESTING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 2137 and os.value_coded = 2147 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \nINNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n-- Observations inside the HIV Testing and Couseling Form \nAND o.obs_group_id in ( \nselect og.obs_id from obs og where og.concept_id = 2385 \n) \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location)\n','2020-04-24 17:48:19',4,'2021-07-22 23:42:46',4,0,NULL,NULL,NULL,'e9556cb4-8e7f-4de4-9384-0b1ebacad149'),(461,'PITC_New_Positive','new tested positive clients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive\n new tested positive clients\n \n 2020-04-24 12:22:19 UTC\n \n 2021-07-22 18:14: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 461\n select distinct patient.patient_id AS Id \n \nfrom obs o \n-- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND o.concept_id = 2165 and o.value_coded = 1738 \nAND patient.voided = 0 AND o.voided = 0 \nAND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n-- PROVIDER INITIATED TESTING AND COUNSELING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 4228 and os.value_coded = 4227 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \n-- NEW TESTER, DOES NOT HAVE A HISTORY OF PREVIOUS TESTING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 2137 and os.value_coded = 2147 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \nINNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n-- Observations inside the HIV Testing and Couseling Form \nAND o.obs_group_id in ( \nselect og.obs_id from obs og where og.concept_id = 2385 \n) \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location)\n','2020-04-24 17:52:19',4,'2021-07-22 23:44:17',4,0,NULL,NULL,NULL,'1a4da7db-09d2-4d28-b38d-bed4cf703253'),(462,'PITC_Repeat_Negative','PITC repeat negative clients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative\n PITC repeat negative clients\n \n 2020-04-24 12:28:12 UTC\n \n 2021-07-22 18:15: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 462\n select distinct patient.patient_id AS Id \n \nfrom obs o \n-- HTS CLIENTS WITH NEGATIVE HIV STATUS BY SEX AND AGE \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND o.concept_id = 2165 and o.value_coded = 1016 \nAND patient.voided = 0 AND o.voided = 0 \nAND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n-- PROVIDER INITIATED TESTING AND COUNSELING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 4228 and os.value_coded = 4227 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \n-- REPEAT TESTER, AVE A HISTORY OF PREVIOUS TESTING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 2137 and os.value_coded = 2146 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \nINNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n-- Observations inside the HIV Testing and Couseling Form \nAND o.obs_group_id in ( \nselect og.obs_id from obs og where og.concept_id = 2385 \n) \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location)\n','2020-04-24 17:58:12',4,'2021-07-22 23:45:21',4,0,NULL,NULL,NULL,'0750dd97-8565-4679-a1c2-052dc049f345'),(463,'PITC_Repeat_Positive','repeat positive clients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive\n repeat positive clients\n \n 2020-04-24 12:31:42 UTC\n \n 2021-07-22 18: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 463\n select distinct patient.patient_id AS Id \n \nfrom obs o \n-- HTS CLIENTS WITH POSITIVE HIV STATUS BY SEX AND AGE \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND o.concept_id = 2165 and o.value_coded = 1738 \nAND patient.voided = 0 AND o.voided = 0 \nAND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n-- PROVIDER INITIATED TESTING AND COUNSELING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 4228 and os.value_coded = 4227 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \n-- REPEAT TESTER, AVE A HISTORY OF PREVIOUS TESTING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 2137 and os.value_coded = 2146 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \nINNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n-- Observations inside the HIV Testing and Couseling Form \nAND o.obs_group_id in ( \nselect og.obs_id from obs og where og.concept_id = 2385 \n) \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location)\n','2020-04-24 18:01:42',4,'2021-07-22 23:46:15',4,0,NULL,NULL,NULL,'9bba9c3a-f886-477f-997f-a7325a668ee7'),(464,'PITC New Negative','PITC New Negative','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC New Negative\n PITC New Negative\n \n 2020-04-24 12:38:16 UTC\n \n 2020-04-24 12:39: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 464\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-04-24 12:38:16',4,'2020-04-24 12:39:14',4,0,NULL,NULL,NULL,'e4a53f3d-9351-4ba9-a039-c1f772b53b05'),(465,'PITC_New_Positive','new positives','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive\n new positives\n \n 2020-04-24 12:45:45 UTC\n \n 2020-04-24 12: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 465\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-04-24 12:45:45',4,'2020-04-24 12:46:35',4,0,NULL,NULL,NULL,'5038a34b-49da-411b-8bb9-bf7ea784fb7e'),(466,'PITC repeat negative','repeat clients who tested negative','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC repeat negative\n repeat clients who tested negative\n \n 2020-04-24 12:48:17 UTC\n \n 2020-04-24 12:49: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 466\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-04-24 12:48:17',4,'2020-04-24 12:49:08',4,0,NULL,NULL,NULL,'e951ced0-d54a-4614-ba74-27a78e8e18df'),(467,'PITC repeat positive','repeating clients who tested positive','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC repeat positive\n repeating clients who tested positive\n \n 2020-04-24 12:50:04 UTC\n \n 2020-04-24 12:50: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 467\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-04-24 12:50:04',4,'2020-04-24 12:50:52',4,0,NULL,NULL,NULL,'e359947f-9dd8-490f-a1c2-056afb801816'),(468,'CITC_Repeat_Positive','repeat clients tested positve','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive\n repeat clients tested positve\n \n 2020-04-27 05:28:31 UTC\n \n 2021-07-22 18:11: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 468\n select distinct patient.patient_id AS Id \n \nfrom obs o \n-- HTS CLIENTS WITH POSITIVE HIV STATUS BY SEX AND AGE \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND o.concept_id = 2165 and o.value_coded = 1738 \nAND patient.voided = 0 AND o.voided = 0 \nAND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n-- CLIENT INITIATED TESTING AND COUNSELING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 4228 and os.value_coded = 4226 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \n-- REPEAT TESTER, HAVE A HISTORY OF PREVIOUS TESTING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 2137 and os.value_coded = 2146 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \nINNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n-- Observations inside the HIV Testing and Couseling Form \nAND o.obs_group_id in ( \nselect og.obs_id from obs og where og.concept_id = 2385 \n) \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location)\n','2020-04-27 10:58:31',4,'2021-07-22 23:41:40',4,0,NULL,NULL,NULL,'3b0f9835-29a4-418d-aaa6-3f8f1d141ece'),(469,'CITC_Repeat_Negative','clients tested negative on repeat visit','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative\n clients tested negative on repeat visit\n \n 2020-04-27 05:30:31 UTC\n \n 2021-07-22 18:10: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 469\n select distinct patient.patient_id AS Id \n \nfrom obs o \n-- HTS CLIENTS WITH NEGATIVE HIV STATUS BY SEX AND AGE \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND o.concept_id = 2165 and o.value_coded = 1016 \nAND patient.voided = 0 AND o.voided = 0 \nAND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n-- CLIENT INITIATED TESTING AND COUNSELING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 4228 and os.value_coded = 4226 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \n-- REPEAT TESTER, HAVE A HISTORY OF PREVIOUS TESTING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 2137 and os.value_coded = 2146 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \nINNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n-- Observations inside the HIV Testing and Couseling Form \nAND o.obs_group_id in ( \nselect og.obs_id from obs og where og.concept_id = 2385 \n) \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location)\n','2020-04-27 11:00:31',4,'2021-07-22 23:40:47',4,0,NULL,NULL,NULL,'a4daa5d2-8e61-44d1-bc37-1b6aba7a6d55'),(470,'CITC_New_Positive','new clients tested positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive\n new clients tested positive\n \n 2020-04-27 05:33:15 UTC\n \n 2021-07-22 18:09: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 470\n select distinct patient.patient_id AS Id \n \nfrom obs o \n-- HTS CLIENTS WITH POSITIVE HIV STATUS BY SEX AND AGE \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND o.concept_id = 2165 and o.value_coded = 1738 \nAND patient.voided = 0 AND o.voided = 0 \nAND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n-- CLIENT INITIATED TESTING AND COUNSELING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 4228 and os.value_coded = 4226 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \n-- NEW TESTER, AVE A HISTORY OF PREVIOUS TESTING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 2137 and os.value_coded = 2147 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \nINNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n-- Observations inside the HIV Testing and Couseling Form \nAND o.obs_group_id in ( \nselect og.obs_id from obs og where og.concept_id = 2385 \n) \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location)\n','2020-04-27 11:03:15',4,'2021-07-22 23:39:48',4,0,NULL,NULL,NULL,'9cd47068-2982-4ca1-a040-bc19ca313349'),(471,'CITC_New_Negative','clients tested negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative\n clients tested negative\n \n 2020-04-27 05:37:47 UTC\n \n 2021-07-22 18:05: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 471\n Select distinct patient.patient_id AS Id \n \nfrom obs o \n-- HTS CLIENTS WITH NEGATIVE HIV STATUS BY SEX AND AGE \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND o.concept_id = 2165 and o.value_coded = 1016 \nAND patient.voided = 0 AND o.voided = 0 \nAND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n-- CLIENT INITIATED TESTING AND COUNSELING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 4228 and os.value_coded = 4226 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \n-- NEW TESTER, AVE A HISTORY OF PREVIOUS TESTING \nAND o.person_id in ( \nselect distinct os.person_id \nfrom obs os \nwhere os.concept_id = 2137 and os.value_coded = 2147 \nAND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \nAND patient.voided = 0 AND o.voided = 0 \n) \n \nINNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n-- Observations inside the HIV Testing and Couseling Form \nAND o.obs_group_id in ( \nselect og.obs_id from obs og where og.concept_id = 2385 \n) \ninner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location)\n','2020-04-27 11:07:47',4,'2021-07-22 23:35:11',4,0,NULL,NULL,NULL,'ebf8843c-2e45-4156-8bbf-867273775513'),(472,'CITC New Positive','CITC New Positive','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC New Positive\n CITC New Positive\n \n 2020-04-27 05:39:50 UTC\n \n 2020-04-27 05:41: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 472\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-04-27 05:39:50',4,'2020-04-27 05:41:21',4,0,NULL,NULL,NULL,'512d2da0-391c-4ec8-b8cc-d9f3028bf456'),(473,'CITC New Negative','CITC New Negative','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC New Negative\n CITC New Negative\n \n 2020-04-27 05:42:28 UTC\n \n 2020-04-27 05: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 473\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-04-27 05:42:28',4,'2020-04-27 05:44:08',4,0,NULL,NULL,NULL,'2c87a371-a86c-4980-aade-4303463e95a5'),(474,'CITC Repeat Positive','CITC Repeat Positive','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC Repeat Positive\n CITC Repeat Positive\n \n 2020-04-27 05:46:33 UTC\n \n 2020-04-27 05:47: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 474\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-04-27 05:46:33',4,'2020-04-27 05:47:32',4,0,NULL,NULL,NULL,'71f59662-0e07-40f6-9c6c-0570bc3ef36f'),(475,'CITC Repeat Negative','CITC Repeat Negative','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC Repeat Negative\n CITC Repeat Negative\n \n 2020-04-27 05:50:11 UTC\n \n 2020-04-27 05:54: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 475\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-04-27 05:50:11',4,'2020-04-27 05:54:46',4,0,NULL,NULL,NULL,'e42b4a1d-bc07-4ab9-b60b-30896100d112'),(476,'CITC','Client Initiated Testing and Counseling section of HTS form','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC\n Client Initiated Testing and Counseling section of HTS form\n \n 2020-04-27 05:56:14 UTC\n \n 2020-04-27 05: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 476\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','2020-04-27 05:56:14',4,'2020-04-27 05:56:21',4,0,NULL,NULL,NULL,'87d3cf9f-40bc-4516-960e-03c17a6b6a09'),(477,'CITC Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC Data Set\n \n 2020-04-27 05:56:21 UTC\n \n 2020-04-27 10:39: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 477\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 CInewNe14F\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 10to14yrs\n \n \n \n \n \n CInewNe14M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n CInewNe19F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n CInewNe19M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n CInewNe24F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n CInewNe24M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n CInewNe29F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 25to29yrs\n \n \n \n \n \n CInewNe29M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 25to29yrs\n \n \n \n \n \n CInewNe34F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 30to34yrs\n \n \n \n \n \n CInewNe34M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 30to34yrs\n \n \n \n \n \n CInewNe39F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 35to39yrs\n \n \n \n \n \n CInewNe39M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 35to39yrs\n \n \n \n \n \n CInewNe44F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 40to44yrs\n \n \n \n \n \n CInewNe44M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 40to44yrs\n \n \n \n \n \n CInewNe49F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 45to49yrs\n \n \n \n \n \n CInewNe49M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 45to49yrs\n \n \n \n \n \n CInewNe50F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 50to100yrs\n \n \n \n \n \n CInewNe50M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 50to100yrs\n \n \n \n \n \n CInewNeg1F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n CInewNeg1M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n CInewNeg4F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n CInewNeg4M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n CInewNeg9F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n CInewNeg9M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n CInewPo14F\n \n \n \n \n \n \n \n \n \n CInewPo14M\n \n \n \n \n \n \n CInewPo19F\n \n \n \n \n \n \n CInewPo19M\n \n \n \n \n \n \n CInewPo24F\n \n \n \n \n \n \n CInewPo24M\n \n \n \n \n \n \n CInewPo29F\n \n \n \n \n \n \n CInewPo29M\n \n \n \n \n \n \n CInewPo34F\n \n \n \n \n \n \n CInewPo34M\n \n \n \n \n \n \n CInewPo39F\n \n \n \n \n \n \n CInewPo39M\n \n \n \n \n \n \n CInewPo44F\n \n \n \n \n \n \n CInewPo44M\n \n \n \n \n \n \n CInewPo49F\n \n \n \n \n \n \n CInewPo49M\n \n \n \n \n \n \n CInewPo50F\n \n \n \n \n \n \n CInewPo50M\n \n \n \n \n \n \n CInewPos1F\n \n \n \n \n \n \n CInewPos1M\n \n \n \n \n \n \n CInewPos4F\n \n \n \n \n \n \n CInewPos4M\n \n \n \n \n \n \n CInewPos9F\n \n \n \n \n \n \n CInewPos9M\n \n \n \n \n \n \n CIrepNe14F\n \n \n \n \n \n \n \n \n \n CIrepNe14M\n \n \n \n \n \n \n CIrepNe19F\n \n \n \n \n \n \n CIrepNe19M\n \n \n \n \n \n \n CIrepNe24F\n \n \n \n \n \n \n CIrepNe24M\n \n \n \n \n \n \n CIrepNe29F\n \n \n \n \n \n \n CIrepNe29M\n \n \n \n \n \n \n CIrepNe34F\n \n \n \n \n \n \n CIrepNe34M\n \n \n \n \n \n \n \n \n \n CIrepNe39F\n \n \n \n \n \n \n CIrepNe39M\n \n \n \n \n \n \n CIrepNe44F\n \n \n \n \n \n \n CIrepNe44M\n \n \n \n \n \n \n CIrepNe49F\n \n \n \n \n \n \n CIrepNe49M\n \n \n \n \n \n \n CIrepNe50F\n \n \n \n \n \n \n CIrepNe50M\n \n \n \n \n \n \n CIrepNeg1F\n \n \n \n \n \n \n CIrepNeg1M\n \n \n \n \n \n \n CIrepNeg4F\n \n \n \n \n \n \n CIrepNeg4M\n \n \n \n \n \n \n CIrepNeg9F\n \n \n \n \n \n \n CIrepNeg9M\n \n \n \n \n \n \n CIrepPo14F\n \n \n \n \n \n \n CIrepPo14M\n \n \n \n \n \n \n CIrepPo19F\n \n \n \n \n \n \n CIrepPo19M\n \n \n \n \n \n \n CIrepPo24F\n \n \n \n \n \n \n CIrepPo24M\n \n \n \n \n \n \n CIrepPo29F\n \n \n \n \n \n \n CIrepPo29M\n \n \n \n \n \n \n CIrepPo34F\n \n \n \n \n \n \n CIrepPo34M\n \n \n \n \n \n \n CIrepPo39F\n \n \n \n \n \n \n CIrepPo39M\n \n \n \n \n \n \n CIrepPo44F\n \n \n \n \n \n \n CIrepPo44M\n \n \n \n \n \n \n CIrepPo49F\n \n \n \n \n \n \n CIrepPo49M\n \n \n \n \n \n \n CIrepPo50F\n \n \n \n \n \n \n CIrepPo50M\n \n \n \n \n \n \n CIrepPos1F\n \n \n \n \n \n \n CIrepPos1M\n \n \n \n \n \n \n CIrepPos4F\n \n \n \n \n \n \n CIrepPos4M\n \n \n \n \n \n \n CIrepPos9F\n \n \n \n \n \n \n CIrepPos9M\n \n \n \n \n \n \n','2020-04-27 05:56:21',4,'2020-04-27 10:39:40',4,0,NULL,NULL,NULL,'3b4a124e-e541-4655-bce1-07595881f037'),(478,'HTS Indeterminate','total inderminate results','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Indeterminate\n total inderminate results\n \n 2020-05-03 10:54:09 UTC\n \n 2020-05-03 10:55: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 478\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.concept_id = 4223 and value_coded = 4220) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 10:54:09',4,'2020-05-03 10:55:12',4,0,NULL,NULL,NULL,'9d8d2a02-6b1b-4f6f-9897-7f2440d60bf5'),(479,'HTS Couple','couples','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Couple\n couples\n \n 2020-05-03 10:58:12 UTC\n \n 2020-05-03 10:59: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 479\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.concept_id = 2166 and value_coded = 2146) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 10:58:12',4,'2020-05-03 10:59:17',4,0,NULL,NULL,NULL,'361c4fa5-4375-42da-935b-00cf7a975167'),(480,'HTS Discordant','Discordant test results','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Discordant\n Discordant test results\n \n 2020-05-03 11:00:30 UTC\n \n 2022-03-17 08:39: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 480\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 concept_id = 2164 \nand person_id in (select person_id from obs where (concept_id = 4225 and value_coded = 2146) \n and obs_datetime >=:startDate \n and obs_datetime <=:endDate \n ) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 11:00:30',4,'2022-03-17 08:39:24',4,0,NULL,NULL,NULL,'49027ad5-be0a-45f5-af20-0926fb6adec9'),(481,'HTS Screened','Clients screened for TB','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Screened\n Clients screened for TB\n \n 2020-05-03 11:05:45 UTC\n \n 2020-05-03 11: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 481\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.concept_id = 2294 and value_coded = 2146) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 11:05:45',4,'2020-05-03 11:06:26',4,0,NULL,NULL,NULL,'3aadefe4-1302-4fff-a140-55a0a634f093'),(482,'HTS Male Condoms','Male condoms distributed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Male Condoms\n Male condoms distributed\n \n 2020-05-03 11:07:57 UTC\n \n 2020-05-03 11:12: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 482\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.concept_id = 4231 and value_coded = 4229) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 11:07:57',4,'2020-05-03 11:12:28',4,0,NULL,NULL,NULL,'9b9b6440-4e3a-4bc4-93eb-e52f32f36cc8'),(483,'HTS Female Condoms','Female condoms distributed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Female Condoms\n Female condoms distributed\n \n 2020-05-03 11:13:25 UTC\n \n 2020-05-03 11:14: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 483\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.concept_id = 4231 and value_coded = 4230) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 11:13:25',4,'2020-05-03 11:14:03',4,0,NULL,NULL,NULL,'18f0954d-4c76-4a30-92e8-306c93bb1b98'),(484,'HTS Confirmatory Negative','COnfirmatory test results negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Confirmatory Negative\n COnfirmatory test results negative\n \n 2020-05-03 11:18:07 UTC\n \n 2020-05-03 11: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 484\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.concept_id = 2161 and value_coded = 1016) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 11:18:07',4,'2020-05-03 11:19:20',4,0,NULL,NULL,NULL,'1ec73fb7-2046-4706-bb66-109eb6ec94c3'),(485,'HTS Confirmatory Positive','Confirmatory test results positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Confirmatory Positive\n Confirmatory test results positive\n \n 2020-05-03 11:21:28 UTC\n \n 2020-05-03 11: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 485\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.concept_id = 2161 and value_coded = 1738) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 11:21:28',4,'2020-05-03 11:22:06',4,0,NULL,NULL,NULL,'78a1c404-42d9-469d-9220-b873114308c2'),(486,'HTS SelfTest Kits','HIVST confirmed HIV positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS SelfTest Kits\n HIVST confirmed HIV positive\n \n 2020-05-03 11:23:54 UTC\n \n 2020-05-03 11: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 486\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.concept_id = 2161 and value_coded = 1738) \nand person_id in (select person_id \nfrom obs \nwhere concept_id = 4662 and value_coded = 4237 \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-03 11:23:54',4,'2020-05-03 11:26:06',4,0,NULL,NULL,NULL,'1377634a-611f-45c3-b42b-0ff16dec16eb'),(487,'HTS Indeterminate','total indeterminate results','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Indeterminate\n total indeterminate results\n \n 2020-05-03 19:06:01 UTC\n \n 2020-05-03 19:07: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 487\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 19:06:01',4,'2020-05-03 19:07:14',4,0,NULL,NULL,NULL,'cbc0f41b-11d1-42c5-819d-2b256a192c7a'),(488,'HTS Couple','Couples only','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Couple\n Couples only\n \n 2020-05-03 19:09:15 UTC\n \n 2020-05-03 19:09: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 488\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 19:09:15',4,'2020-05-03 19:09:57',4,0,NULL,NULL,NULL,'4eae8f2e-2b61-4b25-91f4-027131d2a8e7'),(489,'HTS Discordant','Discordant test results','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Discordant\n Discordant test results\n \n 2020-05-03 19:12:07 UTC\n \n 2020-05-03 19: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 489\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 19:12:07',4,'2020-05-03 19:12:54',4,0,NULL,NULL,NULL,'42279637-8cd0-4097-8948-7ac931af776b'),(490,'HTS Screened','HTS clients screened for TB','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Screened\n HTS clients screened for TB\n \n 2020-05-03 19:13:57 UTC\n \n 2022-03-17 14:20: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 490\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 19:13:57',4,'2022-03-17 14:20:03',4,0,NULL,NULL,NULL,'80d07406-6d62-4289-8d32-887363807775'),(491,'HTS Female Condoms distributed','Condoms distributed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Female Condoms distributed\n Condoms distributed\n \n 2020-05-03 19:18:56 UTC\n \n 2020-05-03 19: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 491\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 19:18:56',4,'2020-05-03 19:21:45',4,0,NULL,NULL,NULL,'9c177ce6-5697-4b84-9093-8e30ac78e3e3'),(492,'HTS Male Condoms','Male condoms distributed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Male Condoms\n Male condoms distributed\n \n 2020-05-03 19:22:24 UTC\n \n 2020-05-03 19:23: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 492\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 19:22:24',4,'2020-05-03 19:23:18',4,0,NULL,NULL,NULL,'5c760a04-22f9-40aa-94a5-397340c8b638'),(493,'HTS Confirmatory Negative','Confirmatory Negative','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Confirmatory Negative\n Confirmatory Negative\n \n 2020-05-03 19:24:40 UTC\n \n 2020-05-03 19:25: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 493\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 19:24:40',4,'2020-05-03 19:25:28',4,0,NULL,NULL,NULL,'f1f06a0f-0afb-4aaa-8542-dd54ff94b6ce'),(494,'HTS Confirmatory Positive','Confirmatory Positive','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Confirmatory Positive\n Confirmatory Positive\n \n 2020-05-03 19:26:24 UTC\n \n 2020-05-03 19:27: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 494\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 19:26:24',4,'2020-05-03 19:27:46',4,0,NULL,NULL,NULL,'5fefbf51-d124-4c3d-a6bd-69bfb0b78f64'),(495,'HTS Self Test Kits','Self Test Kits','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Self Test Kits\n Self Test Kits\n \n 2020-05-03 19:29:29 UTC\n \n 2021-10-19 12:01: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 495\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-03 21:29:29',4,'2021-10-19 14:01:42',4,0,NULL,NULL,NULL,'89fdd6f1-5744-4a2b-9d08-00ef77bb50d8'),(496,'HTS Period Indicator Report','indeterminate,couples,discordant couples,screened for TB,Condoms distribution and confirmatory test results','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Period Indicator Report\n indeterminate,couples,discordant couples,screened for TB,Condoms distribution and confirmatory test results\n \n 2020-05-03 19:38:28 UTC\n \n 2020-05-03 19:38: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 496\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','2020-05-03 19:38:28',4,'2020-05-03 19:38:31',4,0,NULL,NULL,NULL,'dafef277-1393-484d-a947-936a507e03a1'),(497,'HTS Period Indicator 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 HTS Period Indicator Report Data Set\n \n 2020-05-03 19:38:31 UTC\n \n 2020-05-26 13:54: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 497\n \n \n DM_Sex\n \n \n \n \n \n \n \n \n Confirm_N\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 Confirm_P\n \n \n \n \n \n \n \n \n \n Couples\n \n \n \n \n \n \n \n \n \n Discordant\n \n \n \n \n \n \n \n \n \n DistriCD_F\n \n \n \n \n \n \n \n \n \n DistriCD_M\n \n \n \n \n \n \n \n \n \n IND_result\n \n \n \n \n \n \n \n \n \n Indetermin\n \n \n \n \n \n \n \n \n \n Screened_F\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n \n \n \n Screened_M\n \n \n \n \n DM_Sex\n Males\n \n \n \n \n \n','2020-05-03 19:38:31',4,'2020-05-26 13:54:52',4,0,NULL,NULL,NULL,'f25de016-f5c5-4638-b08c-ee3a31c63121'),(498,'HTS Self Test Report','Self Test Kits Distributed and Returned','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Self Test Report\n Self Test Kits Distributed and Returned\n \n 2020-05-03 19:50:04 UTC\n \n 2022-03-09 07:17: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 498\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','2020-05-04 01:20:04',4,'2022-03-09 12:47:59',4,0,NULL,NULL,NULL,'92c28a1a-1d44-40b4-b11f-61a620cea4ea'),(499,'HTS Self Test Kits Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Self Test Kits Data Set\n \n 2020-05-03 19:50:07 UTC\n \n 2022-04-05 07:47: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 499\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 Dis10to14F\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 10to14yrs\n \n \n \n \n \n Dis10to14M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n Dis15+_M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n Dis15to19F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n Dis15to19M\n \n \n \n \n \n \n Dis20to24F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n Dis20to24M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n Dis25to29F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 25to29yrs\n \n \n \n \n \n Dis25to29M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 25to29yrs\n \n \n \n \n \n Dis30to34F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 30to34yrs\n \n \n \n \n \n Dis30to34M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 30to34yrs\n \n \n \n \n \n Dis35to39F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 35to39yrs\n \n \n \n \n \n Dis35to39M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 35to39yrs\n \n \n \n \n \n Dis40to44F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 40to44yrs\n \n \n \n \n \n Dis40to44M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 40to44yrs\n \n \n \n \n \n Dis45to49F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 45to49yrs\n \n \n \n \n \n Dis45to49M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 45to49yrs\n \n \n \n \n \n Dis50_F\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 50to100yrs\n \n \n \n \n \n Dis50_M\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 50to100yrs\n \n \n \n \n \n Po10to14_F\n \n \n \n \n \n \n \n \n \n Po10to14_M\n \n \n \n \n \n \n Po15to19_F\n \n \n \n \n \n \n Po15to19_M\n \n \n \n \n \n \n Po20to24_F\n \n \n \n \n \n \n Po20to24_M\n \n \n \n \n \n \n Po25to29_F\n \n \n \n \n \n \n Po25to29_M\n \n \n \n \n \n \n Po30to34_F\n \n \n \n \n \n \n Po30to34_M\n \n \n \n \n \n \n Po35to39_F\n \n \n \n \n \n \n Po35to39_M\n \n \n \n \n \n \n Po40to44_F\n \n \n \n \n \n \n Po40to44_M\n \n \n \n \n \n \n Po45to49_F\n \n \n \n \n \n \n Po45to49_M\n \n \n \n \n \n \n Po50_F\n \n \n \n \n \n \n Po50_M\n \n \n \n \n \n \n Ret10to14F\n \n \n \n \n \n \n \n \n \n Ret10to14M\n \n \n \n \n \n \n Ret15to19F\n \n \n \n \n \n \n Ret15to19M\n \n \n \n \n \n \n Ret20to24F\n \n \n \n \n \n \n Ret20to24M\n \n \n \n \n \n \n Ret25to29F\n \n \n \n \n \n \n Ret25to29M\n \n \n \n \n \n \n Ret30to34F\n \n \n \n \n \n \n Ret30to34M\n \n \n \n \n \n \n Ret35to39F\n \n \n \n \n \n \n Ret35to39M\n \n \n \n \n \n \n Ret40to44F\n \n \n \n \n \n \n Ret40to44M\n \n \n \n \n \n \n Ret45to49F\n \n \n \n \n \n \n Ret45to49M\n \n \n \n \n \n \n Ret50_F\n \n \n \n \n \n \n Ret50_M\n \n \n \n \n \n \n','2020-05-03 19:50:07',4,'2022-04-05 07:47:13',4,0,NULL,NULL,NULL,'613de36b-b418-42b6-b2db-37cd706fc3fd'),(500,'HTS Indeterminate results','results indeterminate','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Indeterminate results\n results indeterminate\n \n 2020-05-26 13:50:27 UTC\n \n 2020-05-26 13:53: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 500\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-05-26 13:50:27',4,'2020-05-26 13:53:47',4,0,NULL,NULL,NULL,'c15c5dfa-0d7e-463f-a69d-95576f0ebdba'),(501,'HTS Indeterminate results','results indeterminate','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Indeterminate results\n results indeterminate\n \n 2020-05-26 13:52:43 UTC\n \n 2020-05-26 13: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 501\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.concept_id = 4223 and value_coded = 4220) \nand obs_datetime >=:startDate \nand obs_datetime <=:endDate\n','2020-05-26 13:52:43',4,'2020-05-26 13:52:53',4,0,NULL,NULL,NULL,'e5b3353e-8bf6-483a-95a4-cc15c2df3ec9'),(502,'adult_arv_1c_1mnth','clients given 1month supply of 1c ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1c_1mnth\n clients given 1month supply of 1c \n \n 2020-06-04 10:51:42 UTC\n \n 2020-06-04 11:05: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 502\n select distinct o.person_id \nfrom obs o \ninner join (select o.person_id \n from obs o \n inner join \n (select person_id,max(obs_datetime) maxdate \n from obs a \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2201 \n group by person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 2250 and value_coded = 2201 \n and obs_datetime BETWEEN :startDate AND :endDate \n and o.obs_datetime = maxdate \n )b on b.person_id = o.person_id \ninner join \n (select o.person_id \n from obs o \n inner join \n (select person_id,max(obs_datetime) maxdate \n from obs a \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n group by person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 4174 and value_coded = 4175 \n and obs_datetime BETWEEN :startDate AND :endDate \n and o.obs_datetime = maxdate) a on a.person_id = o.person_id \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0\n','2020-06-04 10:51:42',4,'2020-06-04 11:05:55',4,0,NULL,NULL,NULL,'0a6886b5-4642-4477-9218-319ed4782e1d'),(503,'adult_arv_1d_1mnth','clients given 1mnth supply of 1d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1d_1mnth\n clients given 1mnth supply of 1d\n \n 2020-06-04 11:07:29 UTC\n \n 2020-06-16 10: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 503\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2203 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:07:29',4,'2020-06-16 10:38:11',4,0,NULL,NULL,NULL,'d4cdfdf6-35b1-40bb-b177-9c226a164810'),(504,'adult_arv_1e_1mnth','clients given 1month supply of 1e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1e_1mnth\n clients given 1month supply of 1e\n \n 2020-06-04 11:11:23 UTC\n \n 2020-06-16 10:38: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 504\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2205 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:11:23',4,'2020-06-16 10:38:36',4,0,NULL,NULL,NULL,'3b4e39fc-f4d0-493e-b4e5-7effd305b929'),(505,'adult_arv_1f_1mnth','clients given 1month supply of 1f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1f_1mnth\n clients given 1month supply of 1f\n \n 2020-06-04 11:17:19 UTC\n \n 2020-11-20 10:16: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 505\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select person_id from \n (select currentreg.person_id,IFNULL(substitute_regimen,current_reg) ARV_regimen \n from \n (select os.person_id, os.value_coded as current_reg \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 2250 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4175) \n ) \n )currentreg \n left outer JOIN \n ( \n select os.person_id, os.value_coded as substitute_regimen \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 4284 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4175) \n ) \n )substitutereg \n on substitutereg.person_id = currentreg.person_id \n)regimen \nwhere ARV_regimen = 2207)\n','2020-06-04 13:17:19',4,'2020-11-20 12:16:19',4,0,NULL,NULL,NULL,'f059b928-f6d1-4629-87ab-2c9f1c2d4166'),(506,'adult_arv_1g_1mnth','clients given 1month supply of 1g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1g_1mnth\n clients given 1month supply of 1g\n \n 2020-06-04 11:18:32 UTC\n \n 2020-06-16 10:42: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 506\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3672 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:18:32',4,'2020-06-16 10:42:06',4,0,NULL,NULL,NULL,'3badd804-dd17-4f9f-aee1-01ebab4449b9'),(507,'adult_arv_1h_1mnth','clients given 1month supply of 1h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1h_1mnth\n clients given 1month supply of 1h\n \n 2020-06-04 11:20:23 UTC\n \n 2020-06-16 10:42: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 507\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3673 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:20:23',4,'2020-06-16 10:42:34',4,0,NULL,NULL,NULL,'4263e276-f261-406b-bcd0-56cda9464190'),(508,'adult_arv_1j_1mnth','clients given 1 month supply of 1j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1j_1mnth\n clients given 1 month supply of 1j\n \n 2020-06-04 11:22:33 UTC\n \n 2020-11-20 10:56: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 508\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select person_id from \n (select currentreg.person_id,IFNULL(substitute_regimen,current_reg) ARV_regimen \n from \n (select os.person_id, os.value_coded as current_reg \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 2250 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4175) \n ) \n )currentreg \n left outer JOIN \n ( \n select os.person_id, os.value_coded as substitute_regimen \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 4284 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4175) \n ) \n )substitutereg \n on substitutereg.person_id = currentreg.person_id \n)regimen \nwhere ARV_regimen = 4678)\n','2020-06-04 13:22:33',4,'2020-11-20 12:56:17',4,0,NULL,NULL,NULL,'dd8a7cca-c5ee-4aba-8064-4fbe4ab6b3f1'); +INSERT INTO `serialized_object` VALUES (509,'adult_arv_1k_1mnth','clients given 1month supply of 1k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1k_1mnth\n clients given 1month supply of 1k\n \n 2020-06-04 11:23:48 UTC\n \n 2020-06-16 10: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 509\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4679 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:23:48',4,'2020-06-16 10:44:08',4,0,NULL,NULL,NULL,'2b7d8866-e84b-4ccf-9ffa-1707557910f1'),(510,'adult_arv_1m_1mnth','clients given 1month supply of 1m','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1m_1mnth\n clients given 1month supply of 1m\n \n 2020-06-04 11:26:24 UTC\n \n 2020-06-16 10:45: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 510\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4680 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:26:24',4,'2020-06-16 10:45:33',4,0,NULL,NULL,NULL,'8b668641-8cd1-4710-9900-e14afa11d477'),(511,'adult_arv_1n_1mnth','clients given 1month supply of 1n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1n_1mnth\n clients given 1month supply of 1n\n \n 2020-06-04 11:27:29 UTC\n \n 2020-06-16 10: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 511\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4681 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:27:29',4,'2020-06-16 10:45:05',4,0,NULL,NULL,NULL,'a22dae13-6bc7-4d24-9e4d-a0fefab2c9fd'),(512,'adult_arv_1p_1mnth','clients given 1month supply of 1p','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1p_1mnth\n clients given 1month supply of 1p\n \n 2020-06-04 11:30:16 UTC\n \n 2020-06-16 10:46: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 512\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4682 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:30:16',4,'2020-06-16 10:46:13',4,0,NULL,NULL,NULL,'a1837be3-878d-423d-8684-808738f28305'),(513,'adult_arv_1q_1mnth','clients given 1 month supply of 1q','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1q_1mnth\n clients given 1 month supply of 1q\n \n 2020-06-04 11:31:28 UTC\n \n 2020-06-16 10:46: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 513\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4683 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:31:28',4,'2020-06-16 10:46:57',4,0,NULL,NULL,NULL,'c4e93e64-91fe-48e4-a432-8553a70a138b'),(514,'adult_arv_other_1mnth','clients given 1month supply of other arv','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_other_1mnth\n clients given 1month supply of other arv\n \n 2020-06-04 11:35:49 UTC\n \n 2020-06-16 10:48: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 514\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2143 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175 \n)\n','2020-06-04 11:35:49',4,'2020-06-16 10:48:03',4,0,NULL,NULL,NULL,'7c04bae3-26e2-44bb-9f14-46bd23abf3b7'),(515,'adult_arv_1c_3mnth','3mnths supply of 1c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1c_3mnth\n 3mnths supply of 1c\n \n 2020-06-04 11:41:08 UTC\n \n 2020-06-16 10:49: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 515\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2201 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 11:41:08',4,'2020-06-16 10:49:04',4,0,NULL,NULL,NULL,'238a43b6-79ac-46a7-907f-a1e351c5caaa'),(516,'adult_arv_1d_3mnth','3mnths supply of 1d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1d_3mnth\n 3mnths supply of 1d\n \n 2020-06-04 11:42:06 UTC\n \n 2020-06-16 10:49: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 516\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2203 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 11:42:06',4,'2020-06-16 10:49:30',4,0,NULL,NULL,NULL,'1e1e9500-f32d-4290-aab4-935a88bfe130'),(517,'adult_arv_1e_3mnth','3mnths supply of 1e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1e_3mnth\n 3mnths supply of 1e\n \n 2020-06-04 11:46:30 UTC\n \n 2020-06-16 10:49: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 517\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2205 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 11:46:30',4,'2020-06-16 10:49:53',4,0,NULL,NULL,NULL,'db80a24f-af5f-4553-bc8c-9958d082feb4'),(518,'adult_arv_1f_3mnth','3mnths supply of 1f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1f_3mnth\n 3mnths supply of 1f\n \n 2020-06-04 11:48:17 UTC\n \n 2020-11-20 10:53: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 518\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select person_id from \n (select currentreg.person_id,IFNULL(substitute_regimen,current_reg) ARV_regimen \n from \n (select os.person_id, os.value_coded as current_reg \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 2250 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4177) \n ) \n )currentreg \n left outer JOIN \n ( \n select os.person_id, os.value_coded as substitute_regimen \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 4284 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4177) \n ) \n )substitutereg \n on substitutereg.person_id = currentreg.person_id \n)regimen \nwhere ARV_regimen = 2207)\n','2020-06-04 13:48:17',4,'2020-11-20 12:53:53',4,0,NULL,NULL,NULL,'22c820ef-4629-49cb-8ca1-bd2b25c3ff59'),(519,'adult_arv_1g_3mnth','3mnths supply of 1g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1g_3mnth\n 3mnths supply of 1g\n \n 2020-06-04 11:49:57 UTC\n \n 2020-06-16 10:51: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 519\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3672 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 11:49:57',4,'2020-06-16 10:51:22',4,0,NULL,NULL,NULL,'b048d9e0-11c1-4092-8c31-ba6e3acea989'),(520,'adult_arv_1h_3mnth','3mnths supply of 1h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1h_3mnth\n 3mnths supply of 1h\n \n 2020-06-04 11:55:26 UTC\n \n 2020-06-04 11: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 520\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3673 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 11:55:26',4,'2020-06-04 11:57:44',4,0,NULL,NULL,NULL,'1ff080c3-e4fb-4884-bcdb-431d8cf59157'),(521,'adult_arv_1j_3mnth','3mnths supply of 1j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1j_3mnth\n 3mnths supply of 1j\n \n 2020-06-04 11:59:08 UTC\n \n 2020-11-20 10:49: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 521\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select person_id from \n (select currentreg.person_id,IFNULL(substitute_regimen,current_reg) ARV_regimen \n from \n (select os.person_id, os.value_coded as current_reg \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 2250 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4177) \n ) \n )currentreg \n left outer JOIN \n ( \n select os.person_id, os.value_coded as substitute_regimen \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 4284 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4177) \n ) \n )substitutereg \n on substitutereg.person_id = currentreg.person_id \n)regimen \nwhere ARV_regimen = 4678)\n','2020-06-04 13:59:08',4,'2020-11-20 12:49:56',4,0,NULL,NULL,NULL,'5ed7e3c1-afba-4802-a334-a611a9102cc5'),(522,'adult_arv_1k_3mnth','3mnths supply of 1k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1k_3mnth\n 3mnths supply of 1k\n \n 2020-06-04 13:10:45 UTC\n \n 2020-06-04 13:21: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 522\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4679 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 13:10:45',4,'2020-06-04 13:21:56',4,0,NULL,NULL,NULL,'5ee29b38-8294-44d6-bca4-6fd3a2e668ed'),(523,'adult_arv_1m_3mnth','3mnths supply of 1m','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1m_3mnth\n 3mnths supply of 1m\n \n 2020-06-04 13:23:09 UTC\n \n 2020-06-04 13:24: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 523\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4680 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 13:23:09',4,'2020-06-04 13:24:04',4,0,NULL,NULL,NULL,'063a7963-5a7f-4ab4-a444-0db599f8c5a8'),(524,'adult_arv_1n_3mnth','3mnths supply of 1n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1n_3mnth\n 3mnths supply of 1n\n \n 2020-06-04 13:25:04 UTC\n \n 2020-06-04 13:25: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 524\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4681 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 13:25:04',4,'2020-06-04 13:25:38',4,0,NULL,NULL,NULL,'03237de9-f7dc-4446-a8b0-07c73bbf780b'),(525,'adult_arv_1p_3mnth','3mnths supply of 1p','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1p_3mnth\n 3mnths supply of 1p\n \n 2020-06-04 13:27:08 UTC\n \n 2020-06-04 13:27: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 525\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4682 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 13:27:08',4,'2020-06-04 13:27:34',4,0,NULL,NULL,NULL,'5224e59b-88b4-4586-81f5-11719fd1c1ee'),(526,'adult_arv_1q_3mnth','3mnths supply of 1q','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1q_3mnth\n 3mnths supply of 1q\n \n 2020-06-04 13:30:23 UTC\n \n 2020-06-04 13:30: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 526\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4683 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 13:30:23',4,'2020-06-04 13:30:44',4,0,NULL,NULL,NULL,'9cc207d2-97db-47a0-8ff5-e687843138c8'),(527,'adult_arv_other_3mnth','3mnths supply of other regimen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_other_3mnth\n 3mnths supply of other regimen\n \n 2020-06-04 13:34:17 UTC\n \n 2020-06-04 13:34: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 527\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4679 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-04 13:34:17',4,'2020-06-04 13:34:55',4,0,NULL,NULL,NULL,'4d6e10d0-413f-4647-941a-3ae707d69e4d'),(528,'adult_arv_1c_6mnth','6mnths supply of 1c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1c_6mnth\n 6mnths supply of 1c\n \n 2020-06-04 13:45:59 UTC\n \n 2020-06-05 07: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 528\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2201 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 15:45:59',4,'2020-06-05 09:42:05',4,0,NULL,NULL,NULL,'8f096880-4dfb-4ef9-9234-f1ad19ed9fbd'),(529,'adult_arv_1d_6mnth','6mnths supply of 1d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1d_6mnth\n 6mnths supply of 1d\n \n 2020-06-04 13:47:33 UTC\n \n 2020-06-05 07:42: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 529\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2203 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 15:47:33',4,'2020-06-05 09:42:33',4,0,NULL,NULL,NULL,'fdb3a5d9-0f52-4594-862d-32a7067bbf33'),(530,'adult_arv_1e_6mnth','6mnths supply of 1e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1e_6mnth\n 6mnths supply of 1e\n \n 2020-06-04 13:51:21 UTC\n \n 2020-07-15 00:44: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 530\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nand o.person_id in (select os.person_id \n from obs os \n where os.obs_datetime BETWEEN :startDate AND :endDate \n and os.concept_id = 2250 and os.value_coded = 2205 \n ) \nand o.person_id in \n (select os.person_id \n from obs os \n where os.obs_datetime BETWEEN :startDate AND :endDate \n and os.concept_id = 4174 and os.value_coded = 4247 \n) \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0\n','2020-06-04 13:51:21',4,'2020-07-15 00:44:56',4,0,NULL,NULL,NULL,'13ec01be-4c41-4cab-8776-03c2be53fb90'),(531,'adult_arv_1f_6mnth','6mnths supply of 1f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1f_6mnth\n 6mnths supply of 1f\n \n 2020-06-04 13:53:31 UTC\n \n 2020-11-20 10: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 531\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select person_id from \n (select currentreg.person_id,IFNULL(substitute_regimen,current_reg) ARV_regimen \n from \n (select os.person_id, os.value_coded as current_reg \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 2250 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4247) \n ) \n )currentreg \n left outer JOIN \n ( \n select os.person_id, os.value_coded as substitute_regimen \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 4284 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4247) \n ) \n )substitutereg \n on substitutereg.person_id = currentreg.person_id \n)regimen \nwhere ARV_regimen = 2207)\n','2020-06-04 15:53:31',4,'2020-11-20 12:54:18',4,0,NULL,NULL,NULL,'87396003-00c4-433b-b3c1-eb201bd2775c'),(532,'adult_arv_1g_6mnth','6mnths supply of 1g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1g_6mnth\n 6mnths supply of 1g\n \n 2020-06-04 13:54:26 UTC\n \n 2020-06-05 07:44: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 532\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3672 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 15:54:26',4,'2020-06-05 09:44:36',4,0,NULL,NULL,NULL,'884dbb74-6589-4ee4-85af-a349f88cb8e1'),(533,'adult_arv_1h_6mnth','6mnths supply of 1h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1h_6mnth\n 6mnths supply of 1h\n \n 2020-06-04 13:55:28 UTC\n \n 2020-06-16 10:59: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 533\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3673 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 13:55:28',4,'2020-06-16 10:59:55',4,0,NULL,NULL,NULL,'dc3ece21-bfe0-4460-9c09-a12a1663b679'),(534,'adult_arv_1j_6mnth','6mnths supply of 1j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1j_6mnth\n 6mnths supply of 1j\n \n 2020-06-04 13:57:18 UTC\n \n 2020-11-20 10:57: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 534\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select person_id from \n (select currentreg.person_id,IFNULL(substitute_regimen,current_reg) ARV_regimen \n from \n (select os.person_id, os.value_coded as current_reg \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 2250 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4247) \n ) \n )currentreg \n left outer JOIN \n ( \n select os.person_id, os.value_coded as substitute_regimen \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 4284 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4247) \n ) \n )substitutereg \n on substitutereg.person_id = currentreg.person_id \n)regimen \nwhere ARV_regimen = 4678)\n','2020-06-04 15:57:18',4,'2020-11-20 12:57:08',4,0,NULL,NULL,NULL,'4becb473-e1ce-4e72-b4e2-9cf84fcc2366'),(535,'adult_arv_1k_6mnth','6mnths supply of 1k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1k_6mnth\n 6mnths supply of 1k\n \n 2020-06-04 13:58:40 UTC\n \n 2020-06-05 07:46: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 535\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4679 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 15:58:40',4,'2020-06-05 09:46:03',4,0,NULL,NULL,NULL,'3f9ce8e5-1b4a-49b0-bc6d-decfb8fb88c1'),(536,'adult_arv_1m_6mnth','6mnths supply of 1m','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1m_6mnth\n 6mnths supply of 1m\n \n 2020-06-04 14:00:09 UTC\n \n 2020-06-05 07:46: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 536\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4680 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 16:00:09',4,'2020-06-05 09:46:33',4,0,NULL,NULL,NULL,'d7b93a16-4442-49c0-817c-8a1c4b7097ca'),(537,'adult_arv_1n_6mnth','6mnths supply of 1n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1n_6mnth\n 6mnths supply of 1n\n \n 2020-06-04 14:01:31 UTC\n \n 2020-06-05 07:47: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 537\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4681 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 16:01:31',4,'2020-06-05 09:47:14',4,0,NULL,NULL,NULL,'9d4cbcb3-f873-45bf-b00f-32556db829f7'),(538,'adult_arv_1p_6mnth','6mnths supply of 1p','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1p_6mnth\n 6mnths supply of 1p\n \n 2020-06-04 14:02:37 UTC\n \n 2020-06-05 07:47: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 538\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4682 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 16:02:37',4,'2020-06-05 09:47:37',4,0,NULL,NULL,NULL,'6c977b93-8224-48bd-bfcc-fbb1430524ee'),(539,'adult_arv_1q_6mnth','6mnths supply of 1q','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1q_6mnth\n 6mnths supply of 1q\n \n 2020-06-04 14:04:18 UTC\n \n 2020-06-05 07:47: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 539\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4683 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 16:04:18',4,'2020-06-05 09:47:57',4,0,NULL,NULL,NULL,'3925978c-31f1-42dc-a61c-d4c66cb14fdd'),(540,'adult_arv_other_6mnth','6mnths supply of other regimen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_other_6mnth\n 6mnths supply of other regimen\n \n 2020-06-04 14:05:17 UTC\n \n 2020-06-05 07:48: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 540\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2143 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4247 \n)\n','2020-06-04 16:05:17',4,'2020-06-05 09:48:28',4,0,NULL,NULL,NULL,'8b73f162-d9b5-4e96-8139-86586e839271'),(541,'adult_arv_1c_other_months','2wks,1,4,6 months supply of 1c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1c_other_months\n 2wks,1,4,6 months supply of 1c\n \n 2020-06-05 06:57:29 UTC\n \n 2020-06-05 07:48: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 541\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nAND o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2201 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded in (4243,4176,4245,4246) \n)\n','2020-06-05 08:57:29',4,'2020-06-05 09:48:57',4,0,NULL,NULL,NULL,'66511f62-2da4-4c63-8641-034e01c16939'),(542,'adult_arv_1d_other_months','other durations supply of 1d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1d_other_months\n other durations supply of 1d\n \n 2020-06-05 06:58:54 UTC\n \n 2020-07-15 03: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 542\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select os.person_id \n from obs os \n where os.obs_datetime BETWEEN :startDate AND :endDate \n and os.concept_id = 2250 and os.value_coded = 2203 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where oss.obs_datetime BETWEEN :startDate AND :endDate \n and oss.concept_id = 4174 and oss.value_coded in (4243, 4176, 4245, 4246) \n ) \n)\n','2020-06-05 06:58:54',4,'2020-07-15 03:10:40',4,0,NULL,NULL,NULL,'5f87f57a-7059-49f4-986e-783823f5cbab'),(543,'adult_arv_1e_other_months','other duration supply of 1e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1e_other_months\n other duration supply of 1e\n \n 2020-06-05 06:59:45 UTC\n \n 2020-07-15 03:15: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 543\n select distinct(o.person_id) \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select os.person_id \n from obs os \n where os.obs_datetime BETWEEN :startDate AND :endDate \n and os.concept_id = 2250 and os.value_coded = 2205 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where oss.obs_datetime BETWEEN :startDate AND :endDate \n and oss.concept_id = 4174 and oss.value_coded in (4243, 4176, 4245, 4246) \n ) \n)\n','2020-06-05 06:59:45',4,'2020-07-15 03:15:48',4,0,NULL,NULL,NULL,'597e713b-7181-46ce-ae93-07605c62ec37'),(544,'adult_arv_1f_other_months','other duration supply of 1f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1f_other_months\n other duration supply of 1f\n \n 2020-06-05 07:00:40 UTC\n \n 2020-11-20 10:54: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 544\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select person_id from \n (select currentreg.person_id,IFNULL(substitute_regimen,current_reg) ARV_regimen \n from \n (select os.person_id, os.value_coded as current_reg \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 2250 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4243,4176,4245,4246) \n ) \n )currentreg \n left outer JOIN \n ( \n select os.person_id, os.value_coded as substitute_regimen \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 4284 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4243,4176,4245,4246) \n ) \n )substitutereg \n on substitutereg.person_id = currentreg.person_id \n)regimen \nwhere ARV_regimen = 2207)\n','2020-06-05 09:00:40',4,'2020-11-20 12:54:47',4,0,NULL,NULL,NULL,'c83bc608-76be-4774-8065-9e5def272804'),(545,'adult_arv_1g_other_months','other duration supply of 1g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1g_other_months\n other duration supply of 1g\n \n 2020-06-05 07:05:30 UTC\n \n 2020-06-05 07:05: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 545\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3672 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded in (4243,4176,4245,4246) \n)\n','2020-06-05 09:05:30',4,'2020-06-05 09:05:57',4,0,NULL,NULL,NULL,'da485ef1-77d0-4d3d-865d-d8011e6a7560'),(546,'adult_arv_1h_other_months','other duration suppply of 1h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1h_other_months\n other duration suppply of 1h\n \n 2020-06-05 07:06:48 UTC\n \n 2020-07-15 03:11: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 546\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select os.person_id \n from obs os \n where os.obs_datetime BETWEEN :startDate AND :endDate \n and os.concept_id = 2250 and os.value_coded = 3673 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where oss.obs_datetime BETWEEN :startDate AND :endDate \n and oss.concept_id = 4174 and oss.value_coded in (4243, 4176, 4245, 4246) \n ) \n)\n','2020-06-05 07:06:48',4,'2020-07-15 03:11:35',4,0,NULL,NULL,NULL,'4856375f-ed15-4b80-8a69-230643d6918e'),(547,'adult_arv_1j_other_months','other duration supply of 1j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1j_other_months\n other duration supply of 1j\n \n 2020-06-05 07:07:37 UTC\n \n 2020-11-20 10:57: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 547\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \ninner join person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \n \nand o.person_id in ( \n select person_id from \n (select currentreg.person_id,IFNULL(substitute_regimen,current_reg) ARV_regimen \n from \n (select os.person_id, os.value_coded as current_reg \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 2250 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4243,4176,4245,4246) \n ) \n )currentreg \n left outer JOIN \n ( \n select os.person_id, os.value_coded as substitute_regimen \n from obs os \n where MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.concept_id = 4284 \n and os.voided = 0 \n and os.person_id in ( \n select oss.person_id \n from obs oss \n where MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and oss.concept_id = 4174 and oss.value_coded in (4243,4176,4245,4246) \n ) \n )substitutereg \n on substitutereg.person_id = currentreg.person_id \n)regimen \nwhere ARV_regimen = 4678)\n','2020-06-05 09:07:37',4,'2020-11-20 12:57:31',4,0,NULL,NULL,NULL,'a4b6d688-df41-4817-a621-6be6ab32ea59'),(548,'adult_arv_1k_other_months','other duration supply of 1k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1k_other_months\n other duration supply of 1k\n \n 2020-06-05 07:08:26 UTC\n \n 2020-06-05 07:08: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 548\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4679 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded in (4243,4176,4245,4246) \n)\n','2020-06-05 09:08:26',4,'2020-06-05 09:08:46',4,0,NULL,NULL,NULL,'eec6e550-453f-4cb5-a27d-fe60c9dcfdf2'),(549,'adult_arv_1m_other_months','other duration supply of 1m','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1m_other_months\n other duration supply of 1m\n \n 2020-06-05 07:09:19 UTC\n \n 2020-06-05 07:09: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 549\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4680 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded in (4243,4176,4245,4246) \n)\n','2020-06-05 09:09:19',4,'2020-06-05 09:09:41',4,0,NULL,NULL,NULL,'7b67d262-9d16-401d-b604-d91cc253865c'),(550,'adult_arv_1n_other_months','other duration supply of 1n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1n_other_months\n other duration supply of 1n\n \n 2020-06-05 07:10:29 UTC\n \n 2020-06-16 13:34: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 550\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4681 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded in (4243,4176,4245,4246) \n)\n','2020-06-05 07:10:29',4,'2020-06-16 13:34:20',4,0,NULL,NULL,NULL,'952e2836-4856-4364-a91b-b293d5b851d6'),(551,'adult_arv_1p_other_months','other duration supply of 1p','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1p_other_months\n other duration supply of 1p\n \n 2020-06-05 07:16:58 UTC\n \n 2020-06-05 07:17: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 551\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4682 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded in (4243,4176,4245,4246) \n)\n','2020-06-05 09:16:58',4,'2020-06-05 09:17:16',4,0,NULL,NULL,NULL,'be570315-7ba8-466b-8b22-e61f30e0e4c3'),(552,'adult_arv_1q_other_months','other duration supply of 1q','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1q_other_months\n other duration supply of 1q\n \n 2020-06-05 07:17:50 UTC\n \n 2020-06-05 07: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 552\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4683 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded in (4243,4176,4245,4246) \n)\n','2020-06-05 09:17:50',4,'2020-06-05 09:18:06',4,0,NULL,NULL,NULL,'10da0e87-2ff1-4e44-9503-81b78ef95b8b'),(553,'adult_arv_other_other_months','other duration supply of other regimen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_other_other_months\n other duration supply of other regimen\n \n 2020-06-05 07:18:56 UTC\n \n 2020-06-05 07:19: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 553\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2143 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded in (4243,4176,4245,4246) \n)\n','2020-06-05 09:18:56',4,'2020-06-05 09:19:10',4,0,NULL,NULL,NULL,'6f6651ce-3b9c-46e2-9408-1af9b76331bb'),(554,'2020_Pre_ART','pre art PIR for new ART dataset','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_Pre_ART\n pre art PIR for new ART dataset\n \n 2020-06-05 07:21:23 UTC\n \n 2020-06-05 07:21: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 554\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','2020-06-05 09:21:23',4,'2020-06-05 09:21:25',4,0,NULL,NULL,NULL,'825334cf-ea81-4d70-8166-4479b7656543'),(555,'2020_Pre_ART Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_Pre_ART Data Set\n \n 2020-06-05 07:21:25 UTC\n \n 2020-08-04 16:20: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 555\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 EverF14\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 Children 0to14\n \n \n \n \n \n EverF15\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 15+yrs\n \n \n \n \n \n EverM14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n EverM15\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 15+yrs\n \n \n \n \n \n PreF14\n \n \n \n \n \n \n \n \n \n PreF15\n \n \n \n \n \n \n PreM14\n \n \n \n \n \n \n PreM15\n \n \n \n \n \n \n','2020-06-05 07:21:25',4,'2020-08-04 16:20:06',4,0,NULL,NULL,NULL,'a758fb74-1fc9-4fce-a6d8-531decf8be2a'),(557,'2020_ART_Current Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_ART_Current Data Set\n \n 2020-06-05 07:26:21 UTC\n \n 2020-09-14 13:54: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 557\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n DM_Age\n \n \n \n \n \n \n \n \n DefaultF1-\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 DefaultF10\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n DefaultF15\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n DefaultF20\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n DefaultF25\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 25to29yrs\n \n \n \n \n \n DefaultF30\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 30to34yrs\n \n \n \n \n \n DefaultF35\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 35to39yrs\n \n \n \n \n \n DefaultF40\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 40to44yrs\n \n \n \n \n \n DefaultF45\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 45to49yrs\n \n \n \n \n \n DefaultF5-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n DefaultF50\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 50+yrs\n \n \n \n \n \n DefaultF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n DefaultM1-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n DefaultM10\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n DefaultM15\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 15to19yrs\n \n \n \n \n \n DefaultM20\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 20to24yrs\n \n \n \n \n \n DefaultM25\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 25to29yrs\n \n \n \n \n \n DefaultM30\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 30to34yrs\n \n \n \n \n \n DefaultM35\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 35to39yrs\n \n \n \n \n \n DefaultM40\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 40to44yrs\n \n \n \n \n \n DefaultM45\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 45to49yrs\n \n \n \n \n \n DefaultM5-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n DefaultM50\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 50+yrs\n \n \n \n \n \n DefaultM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n DiedClient\n \n \n \n \n \n \n \n \n \n LostToFU\n \n \n \n \n \n \n \n \n \n MMD_F1-4\n \n \n \n \n \n \n \n \n \n MMD_F10-14\n \n \n \n \n \n \n MMD_F15-19\n \n \n \n \n \n \n MMD_F20-24\n \n \n \n \n \n \n MMD_F25-29\n \n \n \n \n \n \n MMD_F30-34\n \n \n \n \n \n \n MMD_F35-39\n \n \n \n \n \n \n MMD_F40-44\n \n \n \n \n \n \n MMD_F45-49\n \n \n \n \n \n \n MMD_F5-9\n \n \n \n \n \n \n MMD_F50\n \n \n \n \n \n \n MMD_F<1\n \n \n \n \n \n \n MMD_M1-4\n \n \n \n \n \n \n MMD_M10-14\n \n \n \n \n \n \n MMD_M15-19\n \n \n \n \n \n \n MMD_M20-24\n \n \n \n \n \n \n MMD_M25-29\n \n \n \n \n \n \n MMD_M30-34\n \n \n \n \n \n \n MMD_M35-39\n \n \n \n \n \n \n MMD_M40-44\n \n \n \n \n \n \n MMD_M45-49\n \n \n \n \n \n \n MMD_M5-9\n \n \n \n \n \n \n MMD_M50\n \n \n \n \n \n \n MMD_M<1\n \n \n \n \n \n \n MissedF1-4\n \n \n \n \n \n \n \n \n \n MissedF10-\n \n \n \n \n \n \n MissedF15-\n \n \n \n \n \n \n MissedF20-\n \n \n \n \n \n \n MissedF25-\n \n \n \n \n \n \n MissedF30-\n \n \n \n \n \n \n MissedF35-\n \n \n \n \n \n \n MissedF40-\n \n \n \n \n \n \n MissedF45-\n \n \n \n \n \n \n MissedF5-9\n \n \n \n \n \n \n MissedF50\n \n \n \n \n \n \n MissedF<1\n \n \n \n \n \n \n MissedM1-4\n \n \n \n \n \n \n MissedM10-\n \n \n \n \n \n \n MissedM15-\n \n \n \n \n \n \n MissedM20-\n \n \n \n \n \n \n MissedM25-\n \n \n \n \n \n \n MissedM30-\n \n \n \n \n \n \n MissedM35-\n \n \n \n \n \n \n MissedM40\n \n \n \n \n \n \n MissedM45-\n \n \n \n \n \n \n MissedM5-9\n \n \n \n \n \n \n MissedM50\n \n \n \n \n \n \n MissedM<1\n \n \n \n \n \n \n Restarted\n \n \n \n \n \n \n \n \n \n SeenFema1-\n \n \n \n \n \n \n \n \n \n SeenFema10\n \n \n \n \n \n \n SeenFema15\n \n \n \n \n \n \n SeenFema20\n \n \n \n \n \n \n SeenFema25\n \n \n \n \n \n \n SeenFema30\n \n \n \n \n \n \n SeenFema35\n \n \n \n \n \n \n SeenFema40\n \n \n \n \n \n \n SeenFema45\n \n \n \n \n \n \n SeenFema5-\n \n \n \n \n \n \n SeenFema50\n \n \n \n \n \n \n SeenFema<1\n \n \n \n \n \n \n SeenMale1-\n \n \n \n \n \n \n SeenMale10\n \n \n \n \n \n \n SeenMale15\n \n \n \n \n \n \n SeenMale20\n \n \n \n \n \n \n SeenMale25\n \n \n \n \n \n \n SeenMale30\n \n \n \n \n \n \n SeenMale35\n \n \n \n \n \n \n SeenMale40\n \n \n \n \n \n \n SeenMale45\n \n \n \n \n \n \n SeenMale5-\n \n \n \n \n \n \n SeenMale50\n \n \n \n \n \n \n SeenMale<1\n \n \n \n \n \n \n StoppedART\n \n \n \n \n \n \n \n \n \n TransferIn\n \n \n \n \n \n \n \n \n \n TransferOu\n \n \n \n \n \n \n \n \n \n newFema1-4\n \n \n \n \n \n \n \n \n \n newFema10-\n \n \n \n \n \n \n newFema15-\n \n \n \n \n \n \n newFema20-\n \n \n \n \n \n \n newFema25-\n \n \n \n \n \n \n newFema30-\n \n \n \n \n \n \n newFema35-\n \n \n \n \n \n \n newFema40-\n \n \n \n \n \n \n newFema45-\n \n \n \n \n \n \n newFema5-9\n \n \n \n \n \n \n newFema50\n \n \n \n \n \n \n newFemale1\n \n \n \n \n \n \n newMale1\n \n \n \n \n \n \n newMale1-4\n \n \n \n \n \n \n newMale10-\n \n \n \n \n \n \n newMale15-\n \n \n \n \n \n \n newMale20-\n \n \n \n \n \n \n newMale25-\n \n \n \n \n \n \n newMale30-\n \n \n \n \n \n \n newMale35-\n \n \n \n \n \n \n newMale40-\n \n \n \n \n \n \n newMale45-\n \n \n \n \n \n \n newMale5-9\n \n \n \n \n \n \n newMale50\n \n \n \n \n \n \n','2020-06-05 09:26:21',4,'2020-09-14 15:54:47',4,0,NULL,NULL,NULL,'81fbbedc-d10c-42aa-9156-e5c93cfd3741'),(558,'adult_arv_2c_1mnth','1month supply of 2c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2c_1mnth\n 1month supply of 2c\n \n 2020-06-05 08:32:14 UTC\n \n 2020-06-16 13:39: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 558\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2210 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:32:14',4,'2020-06-16 13:39:37',4,0,NULL,NULL,NULL,'4a32ce1f-8c3b-4ae7-85dc-eea24672d4d7'),(559,'adult_arv_2d_1mnth','1month supply of 2d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2d_1mnth\n 1month supply of 2d\n \n 2020-06-05 08:33:29 UTC\n \n 2020-06-16 13:40: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 559\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2203 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:33:29',4,'2020-06-16 13:40:52',4,0,NULL,NULL,NULL,'863a96d9-1dcc-4b5c-9277-5b236057bd76'),(560,'adult_arv_2e_1mnth','1month supply of 2e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2e_1mnth\n 1month supply of 2e\n \n 2020-06-05 08:34:22 UTC\n \n 2020-06-16 13: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 560\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3674 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:34:22',4,'2020-06-16 13:41:45',4,0,NULL,NULL,NULL,'8d6cded5-67a7-4121-8f10-0e99e5ee0102'),(561,'adult_arv_2f_1mnth','1month supply of 2f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2f_1mnth\n 1month supply of 2f\n \n 2020-06-05 08:35:08 UTC\n \n 2020-06-16 13: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 561\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3675 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:35:08',4,'2020-06-16 13:42:00',4,0,NULL,NULL,NULL,'04265c85-d096-469c-ac3e-6a78f938ed67'),(562,'adult_arv_2g_1mnth','1month supply of 2g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2g_1mnth\n 1month supply of 2g\n \n 2020-06-05 08:35:54 UTC\n \n 2020-06-16 13:42: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 562\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3676 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:35:54',4,'2020-06-16 13:42:18',4,0,NULL,NULL,NULL,'630e20f6-dc99-460f-a0e2-54b1eea5a00c'),(563,'adult_arv_2h_1mnth','1month supply of 2h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2h_1mnth\n 1month supply of 2h\n \n 2020-06-05 08:37:24 UTC\n \n 2020-06-16 13: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 563\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3677 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:37:24',4,'2020-06-16 13:42:37',4,0,NULL,NULL,NULL,'974cf406-f3d5-4b42-b351-5dcb94f75017'),(564,'adult_arv_2j_1mnth','1month supply of 2j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2j_1mnth\n 1month supply of 2j\n \n 2020-06-05 08:39:19 UTC\n \n 2020-06-16 13:48: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 564\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4689 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:39:19',4,'2020-06-16 13:48:26',4,0,NULL,NULL,NULL,'4d64975e-b01c-46ed-bec8-137a544b7bc7'),(565,'adult_arv_2k_1mnth','1month supply of 2k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2k_1mnth\n 1month supply of 2k\n \n 2020-06-05 08:40:07 UTC\n \n 2020-06-16 13:42: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 565\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4690 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:40:07',4,'2020-06-16 13:42:56',4,0,NULL,NULL,NULL,'3c3d19f1-dad1-4b7b-b994-975f47b7445a'),(566,'adult_arv_2l_1mnth','1month supply of 2l','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2l_1mnth\n 1month supply of 2l\n \n 2020-06-05 08:41:30 UTC\n \n 2020-06-16 13:43: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 566\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4691 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:41:30',4,'2020-06-16 13:43:15',4,0,NULL,NULL,NULL,'b22e2178-de68-4fc6-ae05-601245b6a5b2'),(567,'adult_arv_2m_1mnth','1month supply','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2m_1mnth\n 1month supply\n \n 2020-06-05 08:44:35 UTC\n \n 2020-06-16 13:43: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 567\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4692 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:44:35',4,'2020-06-16 13:43:30',4,0,NULL,NULL,NULL,'a38fa644-0c38-4463-ab26-5c926f886dc9'),(568,'adult_arv_2n_1mnth','1month supply of 2n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2n_1mnth\n 1month supply of 2n\n \n 2020-06-05 08:46:20 UTC\n \n 2020-06-16 13:43: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 568\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4693 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:46:20',4,'2020-06-16 13:43:46',4,0,NULL,NULL,NULL,'2a93bd17-c3eb-4fc4-86fc-ce5849b76bd4'),(569,'adult_arv_2o_1mnth','1month supply of 2o','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2o_1mnth\n 1month supply of 2o\n \n 2020-06-05 08:47:30 UTC\n \n 2020-06-16 13:44: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 569\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4694 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:47:30',4,'2020-06-16 13:44:03',4,0,NULL,NULL,NULL,'eb37ce3b-5110-41b8-a3f0-40f0f3b5db75'),(570,'adult_arv_2p_1mnth','1month supply of 2p','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2p_1mnth\n 1month supply of 2p\n \n 2020-06-05 08:48:45 UTC\n \n 2020-06-16 13:49: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 570\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4695 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 08:48:45',4,'2020-06-16 13:49:22',4,0,NULL,NULL,NULL,'9a54959a-25c3-4cd1-8382-e00379577eeb'),(571,'adult_arv_2q_1mnth','1month supply of 2q','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2q_1mnth\n 1month supply of 2q\n \n 2020-06-05 08:49:34 UTC\n \n 2020-11-20 11:31: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 571\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4849 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-06-05 10:49:34',4,'2020-11-20 13:31:18',4,0,NULL,NULL,NULL,'149baa8e-a071-41bf-99fb-97a781d12330'),(572,'Clients seen given 1 month supply 3a','1month supply of 3a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 3a\n 1month supply of 3a\n \n 2020-06-05 08:51:33 UTC\n \n 2021-07-25 15:37: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 572\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3683)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-06-05 08:51:33',4,'2021-07-25 15:37:23',4,0,NULL,NULL,NULL,'ad771405-a581-4e57-bb60-e2326ee778ca'),(573,'Clients seen given 1 month supply 3b','1month supply of 3b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 3b\n 1month supply of 3b\n \n 2020-06-05 08:52:22 UTC\n \n 2021-07-13 15:10: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 573\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3684)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-06-05 08:52:22',4,'2021-07-13 15:10:31',4,0,NULL,NULL,NULL,'8ce36691-8f7b-42ff-9638-84dc3ce7b473'),(574,'Clients seen given 1 month supply 3c','1month supply of 3c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 3c\n 1month supply of 3c\n \n 2020-06-05 08:53:22 UTC\n \n 2021-07-13 15:11: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 574\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3685)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-06-05 08:53:22',4,'2021-07-13 15:11:00',4,0,NULL,NULL,NULL,'97e72602-8099-4ead-8ed8-63c18ddc337f'),(575,'Clients seen given 1 month supply 3d','1month supply of 3d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 3d\n 1month supply of 3d\n \n 2020-06-05 08:54:01 UTC\n \n 2021-07-13 15:11: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 575\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4706)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-06-05 08:54:01',4,'2021-07-13 15:11:33',4,0,NULL,NULL,NULL,'19fff766-eb8f-41f2-8d76-8f6505bbb9b9'),(576,'Clients seen given 1 month supply 3e','1month supply of 3e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 3e\n 1month supply of 3e\n \n 2020-06-05 08:54:50 UTC\n \n 2021-07-13 15:11: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 576\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4707)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-06-05 08:54:50',4,'2021-07-13 15:11:57',4,0,NULL,NULL,NULL,'b2e90223-56f5-4e04-89e1-d9cc1fc34b17'),(577,'Clients seen given 1 month supply 3f','1month supply of 3f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 3f\n 1month supply of 3f\n \n 2020-06-05 08:58:16 UTC\n \n 2021-07-13 15: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 577\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4708)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-06-05 08:58:16',4,'2021-07-13 15:12:26',4,0,NULL,NULL,NULL,'fdc65c1d-6a93-4a2d-bfc8-19f93d762531'),(578,'Clients seen given 1 month supply 3g','1month supply of 3g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 3g\n 1month supply of 3g\n \n 2020-06-05 08:59:44 UTC\n \n 2021-07-13 15:12: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 578\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4709)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-06-05 08:59:44',4,'2021-07-13 15:12:55',4,0,NULL,NULL,NULL,'72a63ae5-4204-4f3a-803a-6ede62fee967'),(579,'Clients seen given 1 month supply 3h','1month supply of 3h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 3h\n 1month supply of 3h\n \n 2020-06-05 09:00:47 UTC\n \n 2021-07-13 15:13:35 UTC\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 endDate\n \n java.util.Date\n true\n \n \n 579\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4710)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-06-05 09:00:47',4,'2021-07-13 15:13:35',4,0,NULL,NULL,NULL,'a1042d17-e93e-407e-a91e-e6cdf2930ab6'),(580,'adult_arv_2c_3mnth','3months supply of 2c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2c_3mnth\n 3months supply of 2c\n \n 2020-06-05 09:02:19 UTC\n \n 2020-06-05 09:02: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 580\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2210 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:02:19',4,'2020-06-05 11:02:33',4,0,NULL,NULL,NULL,'d0c31b7a-ea56-4f12-a574-924391d2dcb0'),(581,'adult_arv_2d_3mnth','3months supply of 2d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2d_3mnth\n 3months supply of 2d\n \n 2020-06-05 09:03:04 UTC\n \n 2020-06-05 09:03: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 581\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2209 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:03:04',4,'2020-06-05 11:03:19',4,0,NULL,NULL,NULL,'0f6c5bd6-8635-463f-80c8-d5322e97fe54'),(582,'adult_arv_2e_3mnth','3months aupply of 2e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2e_3mnth\n 3months aupply of 2e\n \n 2020-06-05 09:03:56 UTC\n \n 2020-06-05 09:04: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 582\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2205 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:03:56',4,'2020-06-05 11:04:38',4,0,NULL,NULL,NULL,'62d0a57e-51b0-4f3e-967a-12ce18b24778'),(583,'adult_arv_2f_3mnth','3mnths supply of 2f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2f_3mnth\n 3mnths supply of 2f\n \n 2020-06-05 09:09:02 UTC\n \n 2020-06-05 09:09: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 583\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3675 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:09:02',4,'2020-06-05 11:09:21',4,0,NULL,NULL,NULL,'969c9f38-af5e-4595-af5e-346abc080fb5'),(584,'adult_arv_2g_3mnth','3months supply of 2g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2g_3mnth\n 3months supply of 2g\n \n 2020-06-05 09:15:50 UTC\n \n 2020-06-05 09:16: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 584\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3676 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:15:50',4,'2020-06-05 11:16:07',4,0,NULL,NULL,NULL,'c0193c8c-6d28-4787-990e-bb7a38eb6284'),(585,'adult_arv_2h_3mnth','3months supply of 2h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2h_3mnth\n 3months supply of 2h\n \n 2020-06-05 09:17:00 UTC\n \n 2020-06-05 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 585\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 3677 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:17:00',4,'2020-06-05 11:19:06',4,0,NULL,NULL,NULL,'b675b59a-567a-45eb-bb4f-04843ed1719f'),(586,'adult_arv_2j_3mnth','3months supply of 2j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2j_3mnth\n 3months supply of 2j\n \n 2020-06-05 09:19:35 UTC\n \n 2020-06-05 09:19: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 586\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4689 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:19:35',4,'2020-06-05 11:19:53',4,0,NULL,NULL,NULL,'32aaed67-7f8c-40bc-829a-959b7dcb1bfe'),(587,'adult_arv_2k_3mnth','3months supply of 2k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2k_3mnth\n 3months supply of 2k\n \n 2020-06-05 09:21:52 UTC\n \n 2020-06-05 09:22: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 587\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4690 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:21:52',4,'2020-06-05 11:22:08',4,0,NULL,NULL,NULL,'3333bc62-d534-423c-bc79-b477f5296f51'),(588,'adult_arv_2l_3mnth','3months supply of 2l','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2l_3mnth\n 3months supply of 2l\n \n 2020-06-05 09:23:04 UTC\n \n 2020-06-05 09:23: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 588\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 2201 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4691 \n)\n','2020-06-05 11:23:04',4,'2020-06-05 11:23:19',4,0,NULL,NULL,NULL,'aa37e85b-a2fb-41af-97b1-d25b86a87ad5'),(589,'adult_arv_2m_3mnth','3months supply of 2m','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2m_3mnth\n 3months supply of 2m\n \n 2020-06-05 09:23:46 UTC\n \n 2020-06-05 09:24: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 589\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4692 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:23:46',4,'2020-06-05 11:24:00',4,0,NULL,NULL,NULL,'d67a7838-10cf-4ae8-a536-38ba96c2ca9a'),(590,'adult_arv_2n_3mnth','3mnths supply of 2n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2n_3mnth\n 3mnths supply of 2n\n \n 2020-06-05 09:24:28 UTC\n \n 2020-06-05 09:24: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 590\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4693 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:24:28',4,'2020-06-05 11:24:46',4,0,NULL,NULL,NULL,'05a68334-52b7-4a39-8221-f4f3c02b26f6'),(591,'adult_arv_2o_3mnth','3mnths supply of 2o','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2o_3mnth\n 3mnths supply of 2o\n \n 2020-06-05 09:25:16 UTC\n \n 2020-06-05 09:25: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 591\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4694 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:25:16',4,'2020-06-05 11:25:40',4,0,NULL,NULL,NULL,'fe8ca75f-be0f-4047-b0a8-3836ad3c8220'),(592,'adult_arv_2p_3mnth','3months supply of 2p','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2p_3mnth\n 3months supply of 2p\n \n 2020-06-05 09:26:29 UTC\n \n 2020-06-05 09:26: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 592\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4695 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:26:29',4,'2020-06-05 11:26:46',4,0,NULL,NULL,NULL,'34c0a5a2-e192-4423-9067-6c15c57534ea'),(593,'2020_TB_Screening','new dataset TB Screening','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_TB_Screening\n new dataset TB Screening\n \n 2020-06-05 09:27:25 UTC\n \n 2020-06-05 09:27: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 593\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','2020-06-05 11:27:25',4,'2020-06-05 11:27:28',4,0,NULL,NULL,NULL,'5f5679ca-795d-434b-a3e0-354fec02f6e8'),(594,'2020_TB_Screening Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_TB_Screening Data Set\n \n 2020-06-05 09:27:28 UTC\n \n 2020-08-04 17:36: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 594\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 TBCaseAdF\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 15+yrs\n \n \n \n \n \n TBCaseAdM\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 15+yrs\n \n \n \n \n \n TBCaseChF\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n TBCaseChM\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n TBTreatAdF\n \n \n \n \n \n \n \n \n \n TBTreatAdM\n \n \n \n \n \n \n TBTreatChF\n \n \n \n \n \n \n TBTreatChM\n \n \n \n \n \n \n screen14F\n \n \n \n \n \n \n \n \n \n screen14M\n \n \n \n \n \n \n screen15+F\n \n \n \n \n \n \n screen15+M\n \n \n \n \n \n \n seen14F\n \n \n \n \n \n \n \n \n \n seen14M\n \n \n \n \n \n \n seen15+F\n \n \n \n \n \n \n seen15+M\n \n \n \n \n \n \n start14F\n \n \n \n \n \n \n start14M\n \n \n \n \n \n \n start15+F\n \n \n \n \n \n \n start15+M\n \n \n \n \n \n \n','2020-06-05 09:27:28',4,'2020-08-04 17:36:49',4,0,NULL,NULL,NULL,'4d895f5d-ede9-42b0-ae52-7e97a646c2d7'),(595,'adult_arv_2q_3mnth','3mnths supply of 2q','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2q_3mnth\n 3mnths supply of 2q\n \n 2020-06-05 09:29:55 UTC\n \n 2020-11-20 11:33: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 595\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4849 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-06-05 11:29:55',4,'2020-11-20 13:33:12',4,0,NULL,NULL,NULL,'5e16b0e3-6356-4963-8a44-259095ecfb88'),(596,'Clients newly initiated 4c','4c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4c\n 4c\n \n 2020-06-05 09:51:25 UTC\n \n 2021-01-27 22:08: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 596\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2202 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 09:51:25',4,'2021-01-27 22:08:31',4,0,NULL,NULL,NULL,'e9bdc7db-4154-4d56-ae30-e5e22cd2276d'),(597,'Clients newly initiated 4d','4d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4d\n 4d\n \n 2020-06-05 09:54:04 UTC\n \n 2021-01-27 22:19: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 597\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2204 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 09:54:04',4,'2021-01-27 22:19:28',4,0,NULL,NULL,NULL,'2f6f3d47-f7f2-4059-a098-e1164c572f36'),(598,'Clients newly initiated 4e','4e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4e\n 4e\n \n 2020-06-05 09:54:44 UTC\n \n 2021-01-27 22:21: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 598\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3679 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 09:54:44',4,'2021-01-27 22:21:19',4,0,NULL,NULL,NULL,'3b4b75da-e900-4fdf-8594-c25d3a20e047'),(599,'Clients newly initiated 4f','4f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4f\n 4f\n \n 2020-06-05 09:56:08 UTC\n \n 2021-01-27 22:22: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 599\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3680 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 09:56:08',4,'2021-01-27 22:22:42',4,0,NULL,NULL,NULL,'07ea75ac-aa04-47ef-aec5-5c56aaa7143e'),(600,'Clients newly initiated 4g','4g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4g\n 4g\n \n 2020-06-05 09:56:57 UTC\n \n 2021-01-27 22:24: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 600\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4684 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 09:56:57',4,'2021-01-27 22:24:27',4,0,NULL,NULL,NULL,'e0d57b65-99fd-4058-8626-143e4dff86c9'),(601,'Clients newly initiated 4h','4h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4h\n 4h\n \n 2020-06-05 09:58:19 UTC\n \n 2021-01-27 22: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 601\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4685 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 09:58:19',4,'2021-01-27 22:25:35',4,0,NULL,NULL,NULL,'d56c2ea1-4ddf-4d2d-85e3-b25806f12a50'),(602,'Clients newly initiated 4k','4k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4k\n 4k\n \n 2020-06-05 09:59:20 UTC\n \n 2021-01-27 22:29: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 602\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4687 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 09:59:20',4,'2021-01-27 22:29:03',4,0,NULL,NULL,NULL,'938aad64-3bc8-46d7-aaec-36522d65e24b'),(603,'Clients newly initiated 4L','4L','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4L\n 4L\n \n 2020-06-05 10:05:28 UTC\n \n 2021-01-27 22:30: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 603\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4688 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:05:28',4,'2021-01-27 22:30:13',4,0,NULL,NULL,NULL,'368e8627-12e2-4d50-81ce-ac338ad1c858'),(604,'Clients newly initiated 5a','5a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 5a\n 5a\n \n 2020-06-05 10:07:35 UTC\n \n 2021-01-27 22:32: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 604\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3681 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:07:35',4,'2021-01-27 22:32:44',4,0,NULL,NULL,NULL,'2dd7cbae-8054-4270-bf2a-9ec98eef1747'),(605,'Clients newly initiated 5b','5b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 5b\n 5b\n \n 2020-06-05 10:09:31 UTC\n \n 2021-01-27 22:35: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 605\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3682 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:09:31',4,'2021-01-27 22:35:45',4,0,NULL,NULL,NULL,'d8c18842-91aa-4102-a19a-1f48780c4daa'),(606,'Clients newly initiated 5c','5c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 5c\n 5c\n \n 2020-06-05 10:11:40 UTC\n \n 2021-01-27 22:37: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 606\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4696 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:11:40',4,'2021-01-27 22:37:24',4,0,NULL,NULL,NULL,'655a6791-e753-405e-831f-c527d63386ab'),(607,'Clients newly initiated 5d','5d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 5d\n 5d\n \n 2020-06-05 10:12:25 UTC\n \n 2021-01-27 22:39: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 607\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4697 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:12:25',4,'2021-01-27 22:39:19',4,0,NULL,NULL,NULL,'c7e733d9-f5ec-4799-bb83-0f8e38f9a5e1'),(608,'Clients newly initiated 5e','5e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 5e\n 5e\n \n 2020-06-05 10:13:16 UTC\n \n 2021-01-27 22:40: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 608\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4698 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:13:16',4,'2021-01-27 22:40:36',4,0,NULL,NULL,NULL,'09ce91e0-7242-41fa-b68f-551daabefd2e'),(609,'Clients newly initiated 5g','5g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 5g\n 5g\n \n 2020-06-05 10:15:17 UTC\n \n 2021-01-27 22:44: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 609\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4700 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:15:17',4,'2021-01-27 22:44:28',4,0,NULL,NULL,NULL,'c529cc30-cff7-4a9b-8ca6-9bccd505139e'),(610,'Clients newly initiated 5h','5h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 5h\n 5h\n \n 2020-06-05 10:15:50 UTC\n \n 2021-01-27 22:46: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 610\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4701 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:15:50',4,'2021-01-27 22:46:38',4,0,NULL,NULL,NULL,'e316ba5b-a507-493a-8183-3b48bdea3c65'),(611,'Clients newly initiated 6a','6a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 6a\n 6a\n \n 2020-06-05 10:16:53 UTC\n \n 2021-01-27 22:49: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 611\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3686 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:16:53',4,'2021-01-27 22:49:29',4,0,NULL,NULL,NULL,'7cd2486f-34f5-4a78-a016-70512f5b4830'),(612,'Clients newly initiated 6b','6b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 6b\n 6b\n \n 2020-06-05 10:18:54 UTC\n \n 2021-01-27 22:56: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 612\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3687 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:18:54',4,'2021-01-27 22:56:39',4,0,NULL,NULL,NULL,'4b8c4474-fcb5-43e5-9eb8-75695ee52205'),(613,'Clients newly initiated 6c','6c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 6c\n 6c\n \n 2020-06-05 10:19:34 UTC\n \n 2021-01-27 22: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 613\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4702 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:19:34',4,'2021-01-27 22:58:59',4,0,NULL,NULL,NULL,'f3536aac-02a4-42ec-ab92-e43da022e09b'),(614,'2020_COTRIMOX PROPHYLAXIS/DAPSONE','new dataset clients who received CTX','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_COTRIMOX PROPHYLAXIS/DAPSONE\n new dataset clients who received CTX\n \n 2020-06-05 10:20:14 UTC\n \n 2020-06-05 10:20: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 614\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','2020-06-05 12:20:14',4,'2020-06-05 12:20:17',4,0,NULL,NULL,NULL,'8dc80efd-3c35-4d1a-ad4e-5f9f26caeaf5'),(615,'2020_COTRIMOX PROPHYLAXIS/DAPSONE Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_COTRIMOX PROPHYLAXIS/DAPSONE Data Set\n \n 2020-06-05 10:20:17 UTC\n \n 2020-06-06 18:16: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 615\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 CTX_F1-4\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 CTX_F5-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05yrsto14yrs\n \n \n \n \n \n CTX_F<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n CTX_FAdult\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Adults\n \n \n \n \n \n CTX_M1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n CTX_M5-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05yrsto14yrs\n \n \n \n \n \n CTX_M<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n CTX_MAdult\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Adults\n \n \n \n \n \n','2020-06-05 12:20:17',4,'2020-06-06 20:16:22',4,0,NULL,NULL,NULL,'9661c0bc-601a-4b16-b0de-4d891c2d93bc'),(616,'Clients newly initiated 6d','6d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 6d\n 6d\n \n 2020-06-05 10:20:21 UTC\n \n 2021-01-27 23: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 616\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4703 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:20:21',4,'2021-01-27 23:00:12',4,0,NULL,NULL,NULL,'26bd109c-b9bf-41cd-8b76-027713846950'),(617,'Clients newly initiated 6e','6e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 6e\n 6e\n \n 2020-06-05 10:21:00 UTC\n \n 2021-01-27 23: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 617\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4704 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:21:00',4,'2021-01-27 23:03:14',4,0,NULL,NULL,NULL,'9dfe2b8b-dc4c-4708-8672-977b5de9526d'),(618,'Clients newly initiated 6f','6f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 6f\n 6f\n \n 2020-06-05 10:22:22 UTC\n \n 2021-01-27 23:04: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 618\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4705 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 10:22:22',4,'2021-01-27 23:04:14',4,0,NULL,NULL,NULL,'10f50f0b-9282-4d68-9e57-13c17e37b411'),(619,'adult_arv_1c_1mnth','1c 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1c_1mnth\n 1c 1mnth\n \n 2020-06-05 10:42:17 UTC\n \n 2021-01-27 15:47: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 619\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 10:42:17',4,'2021-01-27 15:47:12',4,0,NULL,NULL,NULL,'4d8b2d8b-a165-42ba-abdb-2d881d7cdd0c'),(621,'Clients given CTX in the month','ctx','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given CTX in the month\n ctx\n \n 2020-06-05 10:51:40 UTC\n \n 2020-06-05 10:52: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 621\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand obs_datetime BETWEEN :startDate AND :endDate \nand concept_id = 3728 and value_numeric > 1\n','2020-06-05 12:51:40',4,'2020-06-05 12:52:11',4,0,NULL,NULL,NULL,'afa0260d-641b-45bd-a341-7582b02f70a6'),(622,'adult_arv_1d_1mnth','1d 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1d_1mnth\n 1d 1mnth\n \n 2020-06-05 10:51:52 UTC\n \n 2021-01-27 15:58: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 622\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 10:51:52',4,'2021-01-27 15:58:19',4,0,NULL,NULL,NULL,'00a20283-36e6-43cc-99c3-a9555937e320'),(623,'adult_arv_1e_1mnth','1e 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1e_1mnth\n 1e 1mnth\n \n 2020-06-05 10:54:44 UTC\n \n 2021-01-27 16:12: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 623\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 10:54:44',4,'2021-01-27 16:12:51',4,0,NULL,NULL,NULL,'b693cd81-554d-4b98-ab19-547ef5d1316d'),(624,'adult_arv_1f_1mnth','1f 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1f_1mnth\n 1f 1mnth\n \n 2020-06-05 11:02:36 UTC\n \n 2020-06-05 11:03: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 624\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:02:36',4,'2020-06-05 13:03:17',4,0,NULL,NULL,NULL,'c1745a07-d769-478c-b703-9e00ef10c3fc'),(625,'Plumpy Nut given in the month','RUFT','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Plumpy Nut given in the month\n RUFT\n \n 2020-06-05 11:02:38 UTC\n \n 2020-06-05 11:02: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 625\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand obs_datetime BETWEEN :startDate AND :endDate \nand concept_id = 4167 and value_coded = 4163\n','2020-06-05 13:02:38',4,'2020-06-05 13:02:51',4,0,NULL,NULL,NULL,'085fe744-3c4e-4d96-9621-af1ffeda1e8d'),(626,'F100 given in the month','F100','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n F100 given in the month\n F100\n \n 2020-06-05 11:03:21 UTC\n \n 2020-06-05 11:03: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 626\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand obs_datetime BETWEEN :startDate AND :endDate \nand concept_id = 4167 and value_coded = 4164\n','2020-06-05 13:03:21',4,'2020-06-05 13:03:34',4,0,NULL,NULL,NULL,'1a858146-5ad0-4914-90c6-78770ebc7045'),(627,'F75 given in the month','F75','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n F75 given in the month\n F75\n \n 2020-06-05 11:04:35 UTC\n \n 2020-06-05 11:04: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 627\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand obs_datetime BETWEEN :startDate AND :endDate \nand concept_id = 4167 and value_coded = 4165\n','2020-06-05 13:04:35',4,'2020-06-05 13:04:50',4,0,NULL,NULL,NULL,'a1c3f512-58d0-4b3c-ba09-22f38d76850e'),(628,'adult_arv_1g_1mnth','1g 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1g_1mnth\n 1g 1mnth\n \n 2020-06-05 11:04:39 UTC\n \n 2021-01-27 16:24: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 628\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:04:39',4,'2021-01-27 16:24:35',4,0,NULL,NULL,NULL,'6133c572-3574-4a36-a383-8ba8f154ae4b'),(629,'Other Nutritional Supplement given in the month','other supplement','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Other Nutritional Supplement given in the month\n other supplement\n \n 2020-06-05 11:06:00 UTC\n \n 2020-06-05 11: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 629\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand obs_datetime BETWEEN :startDate AND :endDate \nand concept_id = 4167 and value_coded = 4166\n','2020-06-05 13:06:00',4,'2020-06-05 13:06:13',4,0,NULL,NULL,NULL,'5dcaf597-94b6-40d7-9967-8f145c4c1a54'),(630,'adult_arv_1h_1mnth','1h 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1h_1mnth\n 1h 1mnth\n \n 2020-06-05 11:06:29 UTC\n \n 2021-01-27 16:39: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 630\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:06:29',4,'2021-01-27 16:39:22',4,0,NULL,NULL,NULL,'b36e2da3-c211-4c2d-a01f-4fa0a0fe1fd8'),(631,'adult_arv_1j_1mnth','1j 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1j_1mnth\n 1j 1mnth\n \n 2020-06-05 11:11:22 UTC\n \n 2021-01-27 16: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 631\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:11:22',4,'2021-01-27 16:53:30',4,0,NULL,NULL,NULL,'9560bddf-1def-45f3-8606-ce4adbbfcc19'),(632,'adult_arv_1k_1mnth','1k 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1k_1mnth\n 1k 1mnth\n \n 2020-06-05 11:12:57 UTC\n \n 2021-01-27 16:59: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 632\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:12:57',4,'2021-01-27 16:59:54',4,0,NULL,NULL,NULL,'44fcfb57-e804-4f3e-a7f3-bc488400c481'),(633,'adult_arv_1m_1mnth','1m 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1m_1mnth\n 1m 1mnth\n \n 2020-06-05 11:14:18 UTC\n \n 2021-01-27 17:12: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 633\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:14:18',4,'2021-01-27 17:12:50',4,0,NULL,NULL,NULL,'6dc933e8-a8d7-4b43-89b8-90edc570311a'),(634,'adult_arv_1n_1mnth','1n 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1n_1mnth\n 1n 1mnth\n \n 2020-06-05 11:16:41 UTC\n \n 2021-01-27 17:29: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 634\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:16:41',4,'2021-01-27 17:29:59',4,0,NULL,NULL,NULL,'cb2ca745-f914-4258-aad0-5b57ea870dbd'),(635,'adult_arv_1p_1mnth','1p 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1p_1mnth\n 1p 1mnth\n \n 2020-06-05 11:18:07 UTC\n \n 2021-01-27 17:44: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 635\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:18:07',4,'2021-01-27 17:44:00',4,0,NULL,NULL,NULL,'15aedfaf-51f7-4d96-b706-b3a3280c560a'),(636,'adult_arv_1q_1mnth','1q 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1q_1mnth\n 1q 1mnth\n \n 2020-06-05 11:19:15 UTC\n \n 2021-01-27 17:58: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 636\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:19:15',4,'2021-01-27 17:58:21',4,0,NULL,NULL,NULL,'31689512-e2e3-4401-ad27-ea802bdc3617'),(637,'adult_arv_other_1mnth','other 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_other_1mnth\n other 1mnth\n \n 2020-06-05 11:21:51 UTC\n \n 2021-07-13 11: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 637\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:21:51',4,'2021-07-13 11:05:33',4,0,NULL,NULL,NULL,'449d0ce8-0a40-4591-a309-040dfb083198'),(638,'adult_arv_1c_3mnth','1c 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1c_3mnth\n 1c 3mnths\n \n 2020-06-05 11:24:27 UTC\n \n 2021-01-27 15:49: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 638\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:24:27',4,'2021-01-27 15:49:31',4,0,NULL,NULL,NULL,'2c077d8b-0aa7-401d-aba3-788473928468'),(639,'adult_arv_1d_3mnths','1d 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1d_3mnths\n 1d 3mnths\n \n 2020-06-05 11:25:44 UTC\n \n 2021-01-27 16:00: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 639\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:25:44',4,'2021-01-27 16:00:17',4,0,NULL,NULL,NULL,'e39e1c56-fece-4095-a279-da8ae718544f'),(640,'adult_arv_1e_3mnths','1e 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1e_3mnths\n 1e 3mnths\n \n 2020-06-05 11:27:12 UTC\n \n 2021-01-27 16:16: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 640\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:27:12',4,'2021-01-27 16:16:45',4,0,NULL,NULL,NULL,'6068ee9b-96b7-4c60-ad99-59f129fb2a86'),(641,'adult_arv_1f_3mnths','1f 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1f_3mnths\n 1f 3mnths\n \n 2020-06-05 11:28:37 UTC\n \n 2020-06-05 11:29: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 641\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:28:37',4,'2020-06-05 13:29:15',4,0,NULL,NULL,NULL,'66122df9-8b00-44eb-9895-faabe0421c6c'),(642,'adult_arv_1g_3mnths','1g 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1g_3mnths\n 1g 3mnths\n \n 2020-06-05 11:29:54 UTC\n \n 2021-01-27 16:32: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 642\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:29:54',4,'2021-01-27 16:32:52',4,0,NULL,NULL,NULL,'2e325001-abd4-4c5a-82b9-0ac9886ecbb6'),(643,'adult_arv_1h_3mnths','1h 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1h_3mnths\n 1h 3mnths\n \n 2020-06-05 11:30:54 UTC\n \n 2021-01-27 16:42: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 643\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:30:54',4,'2021-01-27 16:42:06',4,0,NULL,NULL,NULL,'c15f9357-fba2-46f7-96a1-44b25379ccea'),(644,'adult_arv_1j_3mnths','1j 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1j_3mnths\n 1j 3mnths\n \n 2020-06-05 11:32:13 UTC\n \n 2021-01-27 16:55: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 644\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:32:13',4,'2021-01-27 16:55:38',4,0,NULL,NULL,NULL,'e1b0c0ec-23b6-44c7-b80a-851b276f6238'),(645,'adult_arv_1k_3mnths','1k 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1k_3mnths\n 1k 3mnths\n \n 2020-06-05 11:35:55 UTC\n \n 2021-01-27 17: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 645\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:35:55',4,'2021-01-27 17:05:10',4,0,NULL,NULL,NULL,'2e6cd3c8-b48e-4e64-ac85-11c34fdeb49c'),(646,'adult_arv_1m_3mnths','1m 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1m_3mnths\n 1m 3mnths\n \n 2020-06-05 11:37:06 UTC\n \n 2021-01-27 17:14: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 646\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:37:06',4,'2021-01-27 17:14:41',4,0,NULL,NULL,NULL,'ac70448a-01bd-4e80-b1b4-9dffa36380a0'),(647,'adult_arv_1n_3mnths','1n 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1n_3mnths\n 1n 3mnths\n \n 2020-06-05 11:38:09 UTC\n \n 2021-01-27 17:34: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 647\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:38:09',4,'2021-01-27 17:34:59',4,0,NULL,NULL,NULL,'15d01fbf-abf1-4394-9da3-6d2a2b8f02f6'),(648,'adult_arv_1p_3mnths','1p 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1p_3mnths\n 1p 3mnths\n \n 2020-06-05 11:39:05 UTC\n \n 2021-01-27 17:54: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 648\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:39:05',4,'2021-01-27 17:54:50',4,0,NULL,NULL,NULL,'222eaf25-8e7a-4d38-bca4-41642991fe3d'),(649,'adult_arv_1q_3mnths','1q 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1q_3mnths\n 1q 3mnths\n \n 2020-06-05 11:40:02 UTC\n \n 2021-01-27 17: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 649\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:40:02',4,'2021-01-27 17:53:15',4,0,NULL,NULL,NULL,'f6d560ce-615d-4607-a3d0-8ae3435535fe'),(650,'adult_arv_other_3mnths','other 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_other_3mnths\n other 3mnths\n \n 2020-06-05 11:41:25 UTC\n \n 2021-02-04 09:03: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 650\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:41:25',4,'2021-02-04 09:03:37',4,0,NULL,NULL,NULL,'6ab6f0c1-401a-4a74-842f-c97983880745'),(651,'adult_arv_1c_6mnths','1c 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1c_6mnths\n 1c 6mnths\n \n 2020-06-05 11:43:07 UTC\n \n 2021-01-27 15:53: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 651\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:43:07',4,'2021-01-27 15:53:25',4,0,NULL,NULL,NULL,'4b1fc9fe-27bd-4473-b7dd-3f756a47ccb7'),(652,'adult_arv_1d_6mnths','1d 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1d_6mnths\n 1d 6mnths\n \n 2020-06-05 11:44:21 UTC\n \n 2021-01-27 16:08: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 652\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:44:21',4,'2021-01-27 16:08:01',4,0,NULL,NULL,NULL,'eab3ea99-52e0-4ea9-83f3-6711754e40e1'),(653,'adult_arv_1e_6mnths','1e 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1e_6mnths\n 1e 6mnths\n \n 2020-06-05 11:45:53 UTC\n \n 2021-01-27 16:19: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 653\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:45:53',4,'2021-01-27 16:19:28',4,0,NULL,NULL,NULL,'a7fd11c7-b7e0-43ea-b6aa-6c51ec395bcb'),(654,'adult_arv_1f_6mnths','1f 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1f_6mnths\n 1f 6mnths\n \n 2020-06-05 11:47:04 UTC\n \n 2020-06-05 11:47: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 654\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:47:04',4,'2020-06-05 13:47:39',4,0,NULL,NULL,NULL,'1f821fff-33b0-42b0-b62c-430af9d77512'),(655,'adult_arv_1g_6mnths','1g 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1g_6mnths\n 1g 6mnths\n \n 2020-06-05 11:48:04 UTC\n \n 2021-01-27 16:34: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 655\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:48:04',4,'2021-01-27 16:34:52',4,0,NULL,NULL,NULL,'96765b0d-eef0-4990-9602-d27fb6627270'),(656,'adult_arv_1h_6mnths','1h 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1h_6mnths\n 1h 6mnths\n \n 2020-06-05 11:49:10 UTC\n \n 2021-01-27 16:44: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 656\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:49:10',4,'2021-01-27 16:44:47',4,0,NULL,NULL,NULL,'bd0a9a38-fcfc-4dd7-89bd-3d3901b6f37f'),(657,'adult_arv_1j_6mnths','1j 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1j_6mnths\n 1j 6mnths\n \n 2020-06-05 11:51:11 UTC\n \n 2021-01-27 16:57: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 657\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:51:11',4,'2021-01-27 16:57:42',4,0,NULL,NULL,NULL,'f1d1b1e3-7805-49f6-b6e1-3e51ee5ca3c1'),(658,'adult_arv_1k_6mnths','1k 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1k_6mnths\n 1k 6mnths\n \n 2020-06-05 11:52:20 UTC\n \n 2021-01-27 17:07: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 658\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:52:20',4,'2021-01-27 17:07:04',4,0,NULL,NULL,NULL,'508ebf4a-5097-447f-a087-b722c8784233'),(659,'adult_arv_1m_6mnths','1m 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1m_6mnths\n 1m 6mnths\n \n 2020-06-05 11:53:19 UTC\n \n 2021-01-27 17:17: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 659\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:53:19',4,'2021-01-27 17:17:08',4,0,NULL,NULL,NULL,'08b21870-a277-4cf5-83da-3802031cd02d'),(660,'adult_arv_1n_6mnths','1n 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1n_6mnths\n 1n 6mnths\n \n 2020-06-05 11:55:16 UTC\n \n 2021-01-27 17:38: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 660\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:55:16',4,'2021-01-27 17:38:14',4,0,NULL,NULL,NULL,'078738ed-db38-4f25-9963-74e150af6157'),(661,'adult_arv_1p_6mnths','1p 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1p_6mnths\n 1p 6mnths\n \n 2020-06-05 11:56:46 UTC\n \n 2021-01-27 17:36: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 661\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:56:46',4,'2021-01-27 17:36:45',4,0,NULL,NULL,NULL,'a2dcd6db-39bc-469e-ac03-8bfedec4c18f'),(662,'adult_arv_1q_6mnths','1q 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1q_6mnths\n 1q 6mnths\n \n 2020-06-05 11:58:12 UTC\n \n 2021-01-27 18:00: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 662\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:58:12',4,'2021-01-27 18:00:44',4,0,NULL,NULL,NULL,'71007fca-4c23-43ab-81db-9090baa8fb01'),(663,'adult_arv_other_6mnths','other 6mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_other_6mnths\n other 6mnths\n \n 2020-06-05 11:59:58 UTC\n \n 2021-02-04 09:05: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 663\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 11:59:58',4,'2021-02-04 09:05:16',4,0,NULL,NULL,NULL,'24d02723-dc41-4afa-8f45-6da91778130a'),(664,'adult_arv_1c_other_mnths','1c other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1c_other_mnths\n 1c other supply\n \n 2020-06-05 12:03:30 UTC\n \n 2021-01-27 15:56: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 664\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:03:30',4,'2021-01-27 15:56:35',4,0,NULL,NULL,NULL,'fc0771aa-32dc-43da-b4eb-283519fedfd1'),(665,'adult_arv_1d_other_mnths','1d other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1d_other_mnths\n 1d other supply\n \n 2020-06-05 12:07:38 UTC\n \n 2021-01-27 16: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 665\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:07:38',4,'2021-01-27 16:10:12',4,0,NULL,NULL,NULL,'99e2601c-ddcc-42be-a3af-b659bbfdd9ea'),(666,'adult_arv_1e_other_mnths','1e other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1e_other_mnths\n 1e other supply\n \n 2020-06-05 12:09:09 UTC\n \n 2021-01-27 16:20: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 666\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:09:09',4,'2021-01-27 16:20:56',4,0,NULL,NULL,NULL,'5ee5c1d7-9ccf-44f3-b620-c849f9e502cb'),(667,'adult_arv_1f_other_mnths','1f other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1f_other_mnths\n 1f other supply\n \n 2020-06-05 12:10:11 UTC\n \n 2020-06-05 12:10: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 667\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 14:10:11',4,'2020-06-05 14:10:46',4,0,NULL,NULL,NULL,'c54c9e70-972e-475e-accd-d590158089aa'),(668,'adult_arv_1g_other_mnths','1g other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1g_other_mnths\n 1g other supply\n \n 2020-06-05 12:11:10 UTC\n \n 2020-06-05 12:11: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 668\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 14:11:10',4,'2020-06-05 14:11:48',4,0,NULL,NULL,NULL,'6f497b96-793f-444c-b599-b8c84802c8ce'),(669,'adult_arv_1h_other_mnths','1h other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1h_other_mnths\n 1h other supply\n \n 2020-06-05 12:12:15 UTC\n \n 2021-01-27 16:50: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 669\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:12:15',4,'2021-01-27 16:50:25',4,0,NULL,NULL,NULL,'6d91768d-95ad-42ff-a2e8-b994e7af2f3a'),(670,'adult_arv_1j_other_mnths','1j other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1j_other_mnths\n 1j other supply\n \n 2020-06-05 12:14:44 UTC\n \n 2020-06-05 12:15: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 670\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 14:14:44',4,'2020-06-05 14:15:18',4,0,NULL,NULL,NULL,'6176f910-0ee7-4ba9-997e-ce7585f83ae8'),(671,'adult_arv_1k_other_mnths','1k other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1k_other_mnths\n 1k other supply\n \n 2020-06-05 12:15:41 UTC\n \n 2021-01-27 17:08: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 671\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:15:41',4,'2021-01-27 17:08:52',4,0,NULL,NULL,NULL,'6e5cbb5d-f451-47ea-a2fd-9bff1f28f555'),(672,'Missed or defaulted under 28days','missed or defaulted < 28','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Missed or defaulted under 28days\n missed or defaulted < 28\n \n 2020-06-05 12:16:25 UTC\n \n 2024-02-06 09: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 672\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \n and l.location_id = :location or l.parent_location = :location \n -- PATIENTS WHO HAVE NOT SHOWED UP FOR THEIR APPOINTMENT FOR UP TO 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 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) > 0 \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 and os.voided = 0 \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 \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 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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n ) \n \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' \n\n','2020-06-05 17:46:25',4,'2024-02-06 14:50:18',4,0,NULL,NULL,NULL,'a7064d93-cb9d-44f7-b7cb-f0d38313fdb3'),(673,'adult_arv_1m_other_mnths','1m other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1m_other_mnths\n 1m other supply\n \n 2020-06-05 12:16:47 UTC\n \n 2021-01-27 17:18: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 673\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:16:47',4,'2021-01-27 17:18:26',4,0,NULL,NULL,NULL,'9ebb3d1c-52e8-40e7-abc2-871abfdd6ffa'),(674,'adult_arv_1n_other_mnths','1n other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1n_other_mnths\n 1n other supply\n \n 2020-06-05 12:17:46 UTC\n \n 2021-01-27 17: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 674\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:17:46',4,'2021-01-27 17:41:01',4,0,NULL,NULL,NULL,'b829a556-e0e5-4856-8800-ea2560894f62'),(675,'adult_arv_1p_other_mnths','1p other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1p_other_mnths\n 1p other supply\n \n 2020-06-05 12:20:31 UTC\n \n 2021-01-27 17:49: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 675\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:20:31',4,'2021-01-27 17:49:53',4,0,NULL,NULL,NULL,'6843123f-248a-4232-9008-a51ffdc43c5b'),(676,'adult_arv_1q_other_mnths','1q other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_1q_other_mnths\n 1q other supply\n \n 2020-06-05 12:21:42 UTC\n \n 2021-01-27 18: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 676\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:21:42',4,'2021-01-27 18:07:21',4,0,NULL,NULL,NULL,'762d08de-74a3-40fe-9240-1fc904fcb69e'),(677,'Missed or defaulted between 29 and 89 days','missed >29\r\nmissed < 90','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Missed or defaulted between 29 and 89 days\n missed >29 \nmissed < 90\n \n 2020-06-05 12:22:30 UTC\n \n 2024-02-15 09: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 endDateAS\n \n java.util.Date\n true\n \n \n 677\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \n and l.location_id = :location or l.parent_location = :location \n -- PATIENTS WHO HAVE NOT SHOWED UP FOR THEIR APPOINTMENT FOR 4 WEEKS to 3 MONTHS (i.e. 29 to 89 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 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 and DATEDIFF(CAST(:endDate AS DATE),latest_follow_up) <= 89 \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 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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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' \n \n','2020-06-05 17:52:30',4,'2024-02-15 14:42:20',4,0,NULL,NULL,NULL,'5be87aeb-a57c-4a02-83e7-93d560d49fbb'),(678,'adult_arv_other_other_mnths','other other supply','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_other_other_mnths\n other other supply\n \n 2020-06-05 12:23:07 UTC\n \n 2021-02-04 09:06: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 678\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:23:07',4,'2021-02-04 09:06:31',4,0,NULL,NULL,NULL,'c53c49b3-0557-4f1a-9006-1a88e542519d'),(679,'adult_arv_2c_1mnth','2c 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2c_1mnth\n 2c 1mnth\n \n 2020-06-05 12:36:06 UTC\n \n 2021-07-13 14:26: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 679\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:36:06',4,'2021-07-13 14:26:45',4,0,NULL,NULL,NULL,'69830812-bc46-428a-b10e-43a31a982e02'),(680,'LTFU this month','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 LTFU this month\n lost to follow up\n \n 2020-06-05 12:37:18 UTC\n \n 2020-06-05 12:38: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 680\n select distinct o.person_id \nFROM obs o \nINNER JOIN patient ON o.person_id = patient.patient_id \nand o.concept_id = 3752 \nand o.value_datetime in \n ( \n select latestFU from \n ( \n select distinct os.person_id, max(os.value_datetime) AS latestFU, datediff(CAST(:endDate AS DATE), max(value_datetime)) AS \n Num_Days \n from obs os \n inner join person_name pn on os.person_id = pn.person_id \n inner join patient p on pn.person_id = p.patient_id and pn.voided = 0 \n inner join person ps on ps.person_id = p.patient_id and ps.voided = 0 \n where os.concept_id = 3752 \n and obs_datetime <= :endDate \n group by os.person_id \n having Num_Days > 7 \n and Num_Days < 30 \n ) as lost \n ) \nand o.person_id in \n ( \n select person_id from \n ( \n select distinct os.person_id, max(os.value_datetime) AS latestFU, datediff(CAST(:endDate AS DATE), \n max(value_datetime)) AS Num_Days \n from obs os \n inner join person_name pn on os.person_id = pn.person_id \n inner join patient p on pn.person_id = p.patient_id and pn.voided = 0 \n inner join person ps on ps.person_id = p.patient_id and ps.voided = 0 \n where os.concept_id = 3752 \n and obs_datetime <= :endDate \n group by os.person_id \n having Num_Days > 90 \n ) as lost \n ) \n \nAND o.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 4155 and os.value_coded = 2146 and obs_datetime < :endDate and person_id not in \n (select person_id from \n (select person_id who, max(value_datetime) latest \n from obs \n where concept_ID = 2266 \n group by person_id) one, \n \n ( \n select person_id,obs_datetime \n from obs \n where concept_id = 3843 ) two \n \n where who = person_id \n and DATE(obs_datetime) > DATE(latest)) \n ) \n ) \nAND o.person_id not in ( \n select person_id \n from person \n where death_date <= :endDate \n and dead = 1 \n ) \n \n;\n','2020-06-05 14:37:18',4,'2020-06-05 14:38:18',4,0,NULL,NULL,NULL,'f5c2691c-0977-4a4d-957e-2cf973e37bb7'),(681,'adult_arv_2d_1mnth','2d 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2d_1mnth\n 2d 1mnth\n \n 2020-06-05 12:37:55 UTC\n \n 2021-07-13 14:30: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 681\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:37:55',4,'2021-07-13 14:30:11',4,0,NULL,NULL,NULL,'456f6967-04cc-4c2a-8e50-7c99e799eb29'),(682,'adult_arv_2e_1mnth','2e 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2e_1mnth\n 2e 1mnth\n \n 2020-06-05 12:39:33 UTC\n \n 2021-07-13 14:30: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 682\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:39:33',4,'2021-07-13 14:30:44',4,0,NULL,NULL,NULL,'e5b6e482-9ccb-411c-bdf4-8dc43d421947'),(683,'adult_arv_2f_1mnth','2f 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2f_1mnth\n 2f 1mnth\n \n 2020-06-05 12:40:45 UTC\n \n 2021-07-13 14:34: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 683\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:40:45',4,'2021-07-13 14:34:37',4,0,NULL,NULL,NULL,'11aa9360-825c-4aac-ab2a-65d21642765e'),(684,'adult_arv_2g_1mnth','2g 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2g_1mnth\n 2g 1mnth\n \n 2020-06-05 12:41:52 UTC\n \n 2021-07-13 14:35: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 684\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:41:52',4,'2021-07-13 14:35:21',4,0,NULL,NULL,NULL,'b55997df-2560-4087-89ad-f80379b46dd4'),(685,'adult_arv_2h_1mnth','2h 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2h_1mnth\n 2h 1mnth\n \n 2020-06-05 12:43:08 UTC\n \n 2021-07-13 14:36: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 685\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:43:08',4,'2021-07-13 14:36:13',4,0,NULL,NULL,NULL,'4420cacb-9f9e-46ca-b86d-6d03e30a6f3e'),(686,'adult_arv_2j_1mnth','2j 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2j_1mnth\n 2j 1mnth\n \n 2020-06-05 12:44:01 UTC\n \n 2021-07-13 14:37: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 686\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:44:01',4,'2021-07-13 14:37:45',4,0,NULL,NULL,NULL,'e0941c5d-4a20-400b-a0db-862be83470e1'),(687,'adult_arv_2k_1mnth','2k 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2k_1mnth\n 2k 1mnth\n \n 2020-06-05 12:45:06 UTC\n \n 2021-07-13 14:39: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 687\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:45:06',4,'2021-07-13 14:39:23',4,0,NULL,NULL,NULL,'171a878c-c036-4486-a58d-798bc80c7447'),(688,'adult_arv_2l_1mnth','2l 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2l_1mnth\n 2l 1mnth\n \n 2020-06-05 12:46:11 UTC\n \n 2021-07-13 14: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 688\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:46:11',4,'2021-07-13 14:39:38',4,0,NULL,NULL,NULL,'ae5dd3df-007d-4ef2-bcdb-0ef68ff8bc7a'),(689,'adult_arv_2m_1mnth','2m 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2m_1mnth\n 2m 1mnth\n \n 2020-06-05 12:47:05 UTC\n \n 2021-07-13 14: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 689\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:47:05',4,'2021-07-13 14:41:45',4,0,NULL,NULL,NULL,'041a095c-5497-447e-9387-97b4d34df6ab'),(690,'adult_arv_2n_1mnth','2n 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2n_1mnth\n 2n 1mnth\n \n 2020-06-05 12:48:07 UTC\n \n 2021-07-13 14:41: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 690\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:48:07',4,'2021-07-13 14:41:59',4,0,NULL,NULL,NULL,'d64e6398-89a2-4612-985f-dc20dafa92b5'),(691,'adult_arv_2o_1mnth','2o 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2o_1mnth\n 2o 1mnth\n \n 2020-06-05 12:49:21 UTC\n \n 2021-07-13 14:45: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 691\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:49:21',4,'2021-07-13 14:45:11',4,0,NULL,NULL,NULL,'e5455427-d2fd-4398-88d8-372654f69bf7'),(692,'adult_arv_2p_1mnth','2p 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2p_1mnth\n 2p 1mnth\n \n 2020-06-05 12:50:20 UTC\n \n 2021-07-13 14:44: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 692\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:50:20',4,'2021-07-13 14:44:58',4,0,NULL,NULL,NULL,'f299f60d-7b3b-471e-b575-684c94c9ee57'),(693,'adult_arv_2q_1mnth','2q 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2q_1mnth\n 2q 1mnth\n \n 2020-06-05 12:51:42 UTC\n \n 2021-07-13 14:48: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 693\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:51:42',4,'2021-07-13 14:48:08',4,0,NULL,NULL,NULL,'be23c602-cbb1-43ac-b3c8-4c508cc65d66'),(694,'adult_arv_2c_3mnth','2c 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2c_3mnth\n 2c 3mnths\n \n 2020-06-05 12:56:13 UTC\n \n 2021-07-12 09:53: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 694\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:56:13',4,'2021-07-12 09:53:59',4,0,NULL,NULL,NULL,'04215a53-92bb-448c-bc0c-bdf13968fc4a'),(695,'adult_arv_2d_3mnths','2d 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2d_3mnths\n 2d 3mnths\n \n 2020-06-05 12:57:46 UTC\n \n 2020-07-26 12:39: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 695\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 12:57:46',4,'2020-07-26 12:39:30',4,0,NULL,NULL,NULL,'c9657610-a606-46db-8f55-24ded88ddf65'),(696,'Stopped ART this month','stopped ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Stopped ART this month\n stopped ART\n \n 2020-06-05 12:59:50 UTC\n \n 2020-06-05 13:00: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 696\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n where (o.location_id =:location or parent_location =:location) \n AND o.voided = 0 \n and concept_id = 2300 \n AND obs_datetime between :startDate AND :endDate\n','2020-06-05 14:59:50',4,'2020-06-05 15:00:33',4,0,NULL,NULL,NULL,'90747232-9c64-460b-b297-556853c19d27'),(697,'adult_arv_2e_3mnths','2e 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2e_3mnths\n 2e 3mnths\n \n 2020-06-05 13:02:16 UTC\n \n 2020-07-26 12:41: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 697\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:02:16',4,'2020-07-26 12:41:25',4,0,NULL,NULL,NULL,'10f3e3f4-f73e-4d8d-8024-108020886525'),(698,'adult_arv_2f_3mnths','2f 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2f_3mnths\n 2f 3mnths\n \n 2020-06-05 13:04:23 UTC\n \n 2020-07-26 12:43: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 698\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:04:23',4,'2020-07-26 12:43:52',4,0,NULL,NULL,NULL,'c2d8398b-5983-4f3b-b03a-81ca63635377'),(699,'adult_arv_2g_3mnths','2g 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2g_3mnths\n 2g 3mnths\n \n 2020-06-05 13:08:33 UTC\n \n 2020-07-26 12:49: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 699\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:08:33',4,'2020-07-26 12:49:39',4,0,NULL,NULL,NULL,'6a63e39d-88e4-49f2-84d1-63b1a1f1118d'),(700,'adult_arv_2h_3mnths','2h 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2h_3mnths\n 2h 3mnths\n \n 2020-06-05 13:10:20 UTC\n \n 2020-07-26 12:48: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 700\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:10:20',4,'2020-07-26 12:48:18',4,0,NULL,NULL,NULL,'3e13b024-8c5e-4004-b6de-fa643e50b752'),(701,'adult_arv_2j_3mnths','2j 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2j_3mnths\n 2j 3mnths\n \n 2020-06-05 13:11:27 UTC\n \n 2020-07-26 12:51:05 UTC\n \n \n \n \n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 701\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:11:27',4,'2020-07-26 12:51:05',4,0,NULL,NULL,NULL,'1a3b524f-388a-4692-aadf-c2c5c9832870'),(702,'adult_arv_2k_3mnths','2k 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2k_3mnths\n 2k 3mnths\n \n 2020-06-05 13:13:02 UTC\n \n 2020-07-26 12:56: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 702\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:13:02',4,'2020-07-26 12:56:02',4,0,NULL,NULL,NULL,'462e353e-3349-4334-8547-4361d310dd1f'),(703,'adult_arv_2l_3mnths','2l 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2l_3mnths\n 2l 3mnths\n \n 2020-06-05 13:14:56 UTC\n \n 2020-07-26 12:58: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 703\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:14:56',4,'2020-07-26 12:58:05',4,0,NULL,NULL,NULL,'762a506b-5142-4d0b-9a34-7364511b3804'),(704,'4c=AZT-3TC-NVP','4c','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4c=AZT-3TC-NVP\n 4c\n \n 2020-06-05 13:15:30 UTC\n \n 2021-07-01 09: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 704\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:15:30',4,'2021-07-01 09:54:14',4,0,NULL,NULL,NULL,'2333dba3-e4ab-4c96-b28d-b8a55cde3d1d'),(705,'adult_arv_2m_3mnths','2m 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2m_3mnths\n 2m 3mnths\n \n 2020-06-05 13:15:54 UTC\n \n 2020-07-26 13:00: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 705\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:15:54',4,'2020-07-26 13:00:52',4,0,NULL,NULL,NULL,'e39e9c25-717b-4e07-9cf0-9f7f3abfc08e'),(706,'adult_arv_2n_3mnths','2n 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2n_3mnths\n 2n 3mnths\n \n 2020-06-05 13:17:12 UTC\n \n 2020-07-26 13:03: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 706\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:17:12',4,'2020-07-26 13:03:32',4,0,NULL,NULL,NULL,'ff9adb70-4a63-4b77-b3ec-d3425b98afa4'),(707,'4d=AZT-3TC-EFV','4D','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4d=AZT-3TC-EFV\n 4D\n \n 2020-06-05 13:17:34 UTC\n \n 2021-07-01 09: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 707\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:17:34',4,'2021-07-01 09:54:59',4,0,NULL,NULL,NULL,'2090f6ca-5e65-4d41-98e3-b70f29abc483'),(708,'4e=ABC-3TC-NVP','4E','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4e=ABC-3TC-NVP\n 4E\n \n 2020-06-05 13:19:26 UTC\n \n 2021-07-01 09:55: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 708\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:19:26',4,'2021-07-01 09:55:40',4,0,NULL,NULL,NULL,'ee076dba-cc07-4b13-bc62-4d0d32193e03'),(709,'adult_arv_2o_3mnths','2o 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2o_3mnths\n 2o 3mnths\n \n 2020-06-05 13:19:40 UTC\n \n 2020-07-26 13:06: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 709\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:19:40',4,'2020-07-26 13:06:34',4,0,NULL,NULL,NULL,'738cb550-b15d-453e-bb7d-defc4b362956'),(710,'adult_arv_2p_3mnths','2p 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2p_3mnths\n 2p 3mnths\n \n 2020-06-05 13:20:54 UTC\n \n 2020-07-26 13:09: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 710\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:20:54',4,'2020-07-26 13:09:53',4,0,NULL,NULL,NULL,'60662d72-cea5-4ad5-93b0-ce12922fc834'),(711,'adult_arv_2q_3mnths','2q 3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2q_3mnths\n 2q 3mnths\n \n 2020-06-05 13:22:02 UTC\n \n 2020-07-26 13:11: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 711\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:22:02',4,'2020-07-26 13:11:26',4,0,NULL,NULL,NULL,'9ea4bf50-06f1-4028-ab9f-d276a5ea38da'),(712,'4f=ABC-3TC-EFV','4F','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4f=ABC-3TC-EFV\n 4F\n \n 2020-06-05 13:22:28 UTC\n \n 2021-07-01 09:56: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 712\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:22:28',4,'2021-07-01 09:56:17',4,0,NULL,NULL,NULL,'eb90af68-e363-449b-810c-f1075ba677f0'),(713,'4g=AZT-3TC-LPV/r','4g','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4g=AZT-3TC-LPV/r\n 4g\n \n 2020-06-05 13:24:33 UTC\n \n 2021-07-01 09: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 713\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:24:33',4,'2021-07-01 09:57:45',4,0,NULL,NULL,NULL,'3da73ab3-5e2d-4416-adf8-69fda1030aff'),(714,'CI20a: Adult 3rd Line 1month supply 3a','3a 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI20a: Adult 3rd Line 1month supply 3a\n 3a 1mnth\n \n 2020-06-05 13:24:35 UTC\n \n 2021-07-13 15:19: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 714\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:24:35',4,'2021-07-13 15:19:02',4,0,NULL,NULL,NULL,'d5ac0964-e25b-4ac9-bde2-216933143835'),(715,'CI21a: Adult 3rd Line 1month supply 3b','3b 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI21a: Adult 3rd Line 1month supply 3b\n 3b 1mnth\n \n 2020-06-05 13:25:50 UTC\n \n 2021-07-13 15:20: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 715\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:25:50',4,'2021-07-13 15:20:07',4,0,NULL,NULL,NULL,'aecf3360-f578-4223-a2b9-8167716b3ded'),(716,'4h=ABC-3TC-LPV/r','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4h=ABC-3TC-LPV/r\n \n \n 2020-06-05 13:25:57 UTC\n \n 2021-07-01 10:01: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 716\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:25:57',4,'2021-07-01 10:01:31',4,0,NULL,NULL,NULL,'ae250ccd-298b-4520-868e-14f945a7cc19'),(717,'CI22a: Adult 3rd Line 1month supply 3c','3c 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI22a: Adult 3rd Line 1month supply 3c\n 3c 1mnth\n \n 2020-06-05 13:26:59 UTC\n \n 2021-07-13 15:20: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 717\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:26:59',4,'2021-07-13 15:20:22',4,0,NULL,NULL,NULL,'9e32a97e-1aec-4924-8e31-c2870428b351'),(718,'4j=TDF-3TC-DTG(TLD)','4J','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4j=TDF-3TC-DTG(TLD)\n 4J\n \n 2020-06-05 13:27:32 UTC\n \n 2021-07-01 10:02: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 718\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:27:32',4,'2021-07-01 10:02:22',4,0,NULL,NULL,NULL,'30e58b2b-51ad-45c4-ba54-dfa0ee46192f'),(719,'CI40a: Adult 3rd Line 1month supply 3d','3d 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI40a: Adult 3rd Line 1month supply 3d\n 3d 1mnth\n \n 2020-06-05 13:28:21 UTC\n \n 2021-07-13 15:23: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 719\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:28:21',4,'2021-07-13 15:23:54',4,0,NULL,NULL,NULL,'e96450ab-af66-468b-9fe6-59e6dc7039a1'),(720,'CI41a: Adult 3rd Line 1month supply 3e','3e 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI41a: Adult 3rd Line 1month supply 3e\n 3e 1mnth\n \n 2020-06-05 13:29:18 UTC\n \n 2021-07-13 15:24: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 720\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:29:18',4,'2021-07-13 15:24:08',4,0,NULL,NULL,NULL,'9b325a21-8147-4294-8de3-11fe91804147'),(721,'Clients newly initiated 4j','4j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 4j\n 4j\n \n 2020-06-05 13:30:13 UTC\n \n 2021-01-27 22:27: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 721\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4686 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 13:30:13',4,'2021-01-27 22:27:00',4,0,NULL,NULL,NULL,'98e00266-550e-4ac2-ad86-d1bfd1edad02'),(722,'CI42a: Adult 3rd Line 1month supply 3f','3f 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI42a: Adult 3rd Line 1month supply 3f\n 3f 1mnth\n \n 2020-06-05 13:30:30 UTC\n \n 2021-07-13 15:24: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 722\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:30:30',4,'2021-07-13 15:24:22',4,0,NULL,NULL,NULL,'0ec32115-a8ab-4989-8693-4a3b02a2f57f'),(723,'CI43a: Adult 3rd Line 1month supply 3g','3g 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI43a: Adult 3rd Line 1month supply 3g\n 3g 1mnth\n \n 2020-06-05 13:31:51 UTC\n \n 2021-07-13 15:25: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 723\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:31:51',4,'2021-07-13 15:25:40',4,0,NULL,NULL,NULL,'30f95dc0-e9d9-45e0-8780-13b386d0e1ed'),(724,'4k=ABC-3TC-DTG','4K','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4k=ABC-3TC-DTG\n 4K\n \n 2020-06-05 13:31:57 UTC\n \n 2021-07-01 10:03: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 724\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:31:57',4,'2021-07-01 10:03:27',4,0,NULL,NULL,NULL,'788332e7-cc9f-4abb-983a-9c85c218367e'),(725,'CI44a: Adult 3rd Line 1month supply 3h','3h 1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI44a: Adult 3rd Line 1month supply 3h\n 3h 1mnth\n \n 2020-06-05 13:32:56 UTC\n \n 2021-07-13 15:25: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 725\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:32:56',4,'2021-07-13 15:25:58',4,0,NULL,NULL,NULL,'18a4ba21-a27a-41a1-a3a1-407d94e3b6af'),(726,'4L=AZT-3TC-DTG','4L','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4L=AZT-3TC-DTG\n 4L\n \n 2020-06-05 13:33:21 UTC\n \n 2021-07-01 10:03: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 726\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:33:21',4,'2021-07-01 10:03:40',4,0,NULL,NULL,NULL,'9e98473d-8542-491f-ba7a-72eed5bb8cc9'),(727,'5a=AZT-3TC-LPV/r','5a','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 5a=AZT-3TC-LPV/r\n 5a\n \n 2020-06-05 13:37:09 UTC\n \n 2021-07-01 10:04: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 727\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:37:09',4,'2021-07-01 10:04:56',4,0,NULL,NULL,NULL,'90e1122b-ae81-4c9a-85bd-4718d62e8555'),(728,'5b=ABC-3TC-LPV/r','5B','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 5b=ABC-3TC-LPV/r\n 5B\n \n 2020-06-05 13:38:40 UTC\n \n 2021-07-01 10:05: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 728\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:38:40',4,'2021-07-01 10:05:12',4,0,NULL,NULL,NULL,'5724ff33-4897-408c-8c0f-bd4f492421cf'),(729,'5c=ABC-3TC-DRV/r','5C','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 5c=ABC-3TC-DRV/r\n 5C\n \n 2020-06-05 13:41:08 UTC\n \n 2021-07-01 10:06: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 729\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:41:08',4,'2021-07-01 10:06:05',4,0,NULL,NULL,NULL,'fcba5f96-f8b0-4cee-a432-d8a812214c91'),(730,'5d=AZT-3TC-DRV/r','5D','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 5d=AZT-3TC-DRV/r\n 5D\n \n 2020-06-05 13:43:45 UTC\n \n 2021-07-01 10: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 730\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:43:45',4,'2021-07-01 10:06:20',4,0,NULL,NULL,NULL,'c755ea49-186f-44fc-b6c6-9063230d3480'),(731,'5e=AZT-3TC-ABC','5e','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 5e=AZT-3TC-ABC\n 5e\n \n 2020-06-05 13:44:53 UTC\n \n 2021-07-01 10:07: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 731\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:44:53',4,'2021-07-01 10:07:11',4,0,NULL,NULL,NULL,'19dddce8-40b7-4851-ae3a-c3a1cb14eb91'),(732,'5f=AZT-3TC-DTG','5f','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 5f=AZT-3TC-DTG\n 5f\n \n 2020-06-05 13:47:24 UTC\n \n 2021-07-01 10:07: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 732\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:47:24',4,'2021-07-01 10:07:29',4,0,NULL,NULL,NULL,'949e2eab-7153-4142-b71a-59e1a1defede'),(733,'Clients newly initiated 5f','5f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 5f\n 5f\n \n 2020-06-05 13:48:37 UTC\n \n 2021-01-27 22: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 733\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4699 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-06-05 13:48:37',4,'2021-01-27 22:42:15',4,0,NULL,NULL,NULL,'c2568b3b-6226-4d7b-a190-b337501d1731'),(734,'5g=AZT-3TC-ATVr/','5G','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 5g=AZT-3TC-ATVr/\n 5G\n \n 2020-06-05 13:50:29 UTC\n \n 2021-07-01 10: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 734\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:50:29',4,'2021-07-01 10:08:22',4,0,NULL,NULL,NULL,'286bc570-0ccd-48ff-862d-211475082a7a'),(735,'5h=ABC-3TC-ATV/r','5h','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 5h=ABC-3TC-ATV/r\n 5h\n \n 2020-06-05 13:52:03 UTC\n \n 2021-07-01 10:09: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 735\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:52:03',4,'2021-07-01 10:09:01',4,0,NULL,NULL,NULL,'8d6b09b2-2781-4559-bfc0-a3c5678536b4'),(736,'6a=RAL-ETV-LPV/r','6a','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 6a=RAL-ETV-LPV/r\n 6a\n \n 2020-06-05 13:53:49 UTC\n \n 2021-07-01 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 736\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:53:49',4,'2021-07-01 10:09:36',4,0,NULL,NULL,NULL,'23792b6c-5b46-4a98-9fe6-1d26d4f91e9e'),(737,'6b=RAL-ETV-DRV/r','6b','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 6b=RAL-ETV-DRV/r\n 6b\n \n 2020-06-05 13:55:09 UTC\n \n 2021-07-01 10:09: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 737\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:55:09',4,'2021-07-01 10:09:59',4,0,NULL,NULL,NULL,'5449106c-244d-4d19-ad83-bba3f01589e7'),(738,'6c=RAL+ETV+DRV/r','6C','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 6c=RAL+ETV+DRV/r\n 6C\n \n 2020-06-05 13:57:19 UTC\n \n 2021-07-01 10:10: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 738\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:57:19',4,'2021-07-01 10:10:51',4,0,NULL,NULL,NULL,'aa99445e-54bd-4de8-9ef1-9a888fd68239'),(739,'6d=TDF-3TC-DRV/r+RAL','6D','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 6d=TDF-3TC-DRV/r+RAL\n 6D\n \n 2020-06-05 13:59:01 UTC\n \n 2021-07-01 10:11: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 739\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 13:59:01',4,'2021-07-01 10:11:04',4,0,NULL,NULL,NULL,'367ded00-770e-478f-a366-2c5ca91c2567'),(740,'6e=RAL+DRV/r','6E','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 6e=RAL+DRV/r\n 6E\n \n 2020-06-05 14:00:26 UTC\n \n 2021-07-01 10:12: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 740\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 14:00:26',4,'2021-07-01 10:12:05',4,0,NULL,NULL,NULL,'a8e0b35d-cf9a-4f1f-8995-c7a9e28b1103'),(741,'6f=AZT+3TC+DRV/r+ETV','6F','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 6f=AZT+3TC+DRV/r+ETV\n 6F\n \n 2020-06-05 14:02:22 UTC\n \n 2021-07-01 10: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 741\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 14:02:22',4,'2021-07-01 10:12:20',4,0,NULL,NULL,NULL,'0952cfb3-6f9b-4d27-b94b-4c25ba0c99e7'),(742,'Cotrimox Prophylaxis/Dapsone','CTX','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Cotrimox Prophylaxis/Dapsone\n CTX\n \n 2020-06-05 14:06:03 UTC\n \n 2020-06-05 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 742\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 16:06:03',4,'2020-06-05 16:06:48',4,0,NULL,NULL,NULL,'12dfb355-bf17-4ee3-a267-b047f38a89b8'),(743,'Missed or defaulted under 28days','missed appointments under 28 days','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Missed or defaulted under 28days\n missed appointments under 28 days\n \n 2020-06-05 14:06:51 UTC\n \n 2020-06-05 14:08: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 743\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 16:06:51',4,'2020-06-05 16:08:00',4,0,NULL,NULL,NULL,'26fb300b-c224-45ae-a82e-94786101c82d'),(744,'RUFT','Plumpy-nut','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n RUFT\n Plumpy-nut\n \n 2020-06-05 14:08:10 UTC\n \n 2020-06-05 14:09: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 744\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 16:08:10',4,'2020-06-05 16:09:03',4,0,NULL,NULL,NULL,'e72ff52c-b8c7-4728-bf7b-747e208b3e06'),(745,'Missed or defaulted between 29 and 89 days','Missed or defaulted between 29 and 89 days','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Missed or defaulted between 29 and 89 days\n Missed or defaulted between 29 and 89 days\n \n 2020-06-05 14:08:54 UTC\n \n 2020-06-05 14:09: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 745\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 16:08:54',4,'2020-06-05 16:09:29',4,0,NULL,NULL,NULL,'6ec03f54-c1f7-49b4-9332-c7c9aa994579'),(746,'Given F100 in the month','F100','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Given F100 in the month\n F100\n \n 2020-06-05 14:09:44 UTC\n \n 2020-06-05 14:10: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 746\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 16:09:44',4,'2020-06-05 16:10:29',4,0,NULL,NULL,NULL,'052f159f-57d1-4597-94ae-d81c0876610d'),(747,'Given F75 in the month','F75','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Given F75 in the month\n F75\n \n 2020-06-05 14:10:52 UTC\n \n 2020-06-05 14:12: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 747\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 16:10:52',4,'2020-06-05 16:12:03',4,0,NULL,NULL,NULL,'a63995e1-38a2-4c49-8189-7e2eff852513'),(748,'Other Nutritional Supplement given in the month','other','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Other Nutritional Supplement given in the month\n other\n \n 2020-06-05 14:12:35 UTC\n \n 2020-06-05 14:13: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 748\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 16:12:35',4,'2020-06-05 16:13:16',4,0,NULL,NULL,NULL,'092667a0-a0a3-4f6e-b25d-963a76c74814'),(750,'Children ARV Regimen 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 Data Set\n \n 2020-06-05 14:19:22 UTC\n \n 2020-06-05 16:09: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 750\n \n \n DM_Weight\n \n \n \n \n \n \n \n \n 4L03to3.9\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_Weight\n 03to3.9kg\n \n \n \n \n \n 4L10to13.9\n \n \n \n \n DM_Weight\n 10to13.9kg\n \n \n \n \n \n 4L14to19.9\n \n \n \n \n DM_Weight\n 14to19.9kg\n \n \n \n \n \n 4L20to24.9\n \n \n \n \n DM_Weight\n 20to24.9kg\n \n \n \n \n \n 4L25to34.9\n \n \n \n \n DM_Weight\n 25to34.9kg\n \n \n \n \n \n 4L4to5.9\n \n \n \n \n DM_Weight\n 04to5.9kg\n \n \n \n \n \n 4L6to9.9\n \n \n \n \n DM_Weight\n 06to9.9kg\n \n \n \n \n \n 4c03to3.9\n \n \n \n \n \n \n \n \n \n 4c10to13.9\n \n \n \n \n \n \n 4c14to19.9\n \n \n \n \n \n \n 4c20to24.9\n \n \n \n \n \n \n 4c25to34.9\n \n \n \n \n \n \n 4c4to5.9\n \n \n \n \n \n \n 4c6to9.9\n \n \n \n \n \n \n 4d0.3to3.9\n \n \n \n \n \n \n \n \n \n 4d10to13.9\n \n \n \n \n \n \n 4d14to19.9\n \n \n \n \n \n \n 4d20to24.9\n \n \n \n \n \n \n 4d25to34.9\n \n \n \n \n \n \n 4d4to5.9\n \n \n \n \n \n \n 4d6to9.9\n \n \n \n \n \n \n 4e0.3to3.9\n \n \n \n \n \n \n \n \n \n 4e10to13.9\n \n \n \n \n \n \n 4e14to19.9\n \n \n \n \n \n \n 4e20to24.9\n \n \n \n \n \n \n 4e25to34.9\n \n \n \n \n \n \n 4e4to5.9\n \n \n \n \n \n \n 4e6to9.9\n \n \n \n \n \n \n 4f0.3to3.9\n \n \n \n \n \n \n \n \n \n 4f10to13.9\n \n \n \n \n \n \n 4f14to19.9\n \n \n \n \n \n \n 4f20to24.9\n \n \n \n \n \n \n 4f25to34.9\n \n \n \n \n \n \n 4f4to5.9\n \n \n \n \n \n \n 4f6to9.9\n \n \n \n \n \n \n 4g0.3to3.9\n \n \n \n \n \n \n \n \n \n 4g10to13.9\n \n \n \n \n \n \n 4g14to19.9\n \n \n \n \n \n \n 4g20to24.9\n \n \n \n \n \n \n 4g25to34.9\n \n \n \n \n \n \n 4g4to5.9\n \n \n \n \n \n \n 4g6to9.9\n \n \n \n \n \n \n 4h0.3to3.9\n \n \n \n \n \n \n \n \n \n 4h10to13.9\n \n \n \n \n \n \n 4h14to19.9\n \n \n \n \n \n \n 4h20to24.9\n \n \n \n \n \n \n 4h25to34.9\n \n \n \n \n \n \n 4h4to5.9\n \n \n \n \n \n \n 4h6to9.9\n \n \n \n \n \n \n 4j0.3to3.9\n \n \n \n \n \n \n \n \n \n 4j10to13.9\n \n \n \n \n \n \n 4j14to19.9\n \n \n \n \n \n \n 4j20to24.9\n \n \n \n \n \n \n 4j25to34.9\n \n \n \n \n \n \n 4j4to5.9\n \n \n \n \n \n \n 4j6to9.9\n \n \n \n \n \n \n 4k0.3to3.9\n \n \n \n \n \n \n \n \n \n 4k10to13.9\n \n \n \n \n \n \n 4k14to19.9\n \n \n \n \n \n \n 4k20to24.9\n \n \n \n \n \n \n 4k25to34.9\n \n \n \n \n \n \n 4k4to5.9\n \n \n \n \n \n \n 4k6to9.9\n \n \n \n \n \n \n','2020-06-05 16:19:22',4,'2020-06-05 18:09:53',4,0,NULL,NULL,NULL,'86987ed4-9fb6-46c9-9376-124ca29b26cb'),(751,'Stopped ART this month','stopped this month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Stopped ART this month\n stopped this month\n \n 2020-06-05 15:34:17 UTC\n \n 2020-06-05 15:37: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 751\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-05 17:34:17',4,'2020-06-05 17:37:55',4,0,NULL,NULL,NULL,'3339dfc7-cd36-4231-b31e-5390963065ab'),(752,'2020_adult_arv_1stline_regimen','new dataset ADULT ARV REGIMEN AT THE END OF THE MONTH (15+)','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_adult_arv_1stline_regimen\n new dataset ADULT ARV REGIMEN AT THE END OF THE MONTH (15+)\n \n 2020-06-05 15:51:46 UTC\n \n 2020-07-26 09:11: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 752\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','2020-06-05 15:51:46',4,'2020-07-26 09:11:25',4,0,NULL,NULL,NULL,'bf495055-881f-4d8f-a313-034368641292'),(753,'2020_ADULT ARV REGIMEN AT THE END OF THE MONTH (15+) Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_ADULT ARV REGIMEN AT THE END OF THE MONTH (15+) Data Set\n \n 2020-06-05 15:51:49 UTC\n \n 2021-01-27 14:00: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 753\n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 1c_1mnth\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_Age\n 15+yrs\n \n \n \n \n \n 1c_3mnths\n \n \n \n \n \n \n \n \n \n 1c_6mnths\n \n \n \n \n \n \n \n \n \n 1c_other\n \n \n \n \n \n \n \n \n \n 1d_1mnth\n \n \n \n \n \n \n \n \n \n 1d_3mnths\n \n \n \n \n \n \n \n \n \n 1d_6mnths\n \n \n \n \n \n \n \n \n \n 1d_other\n \n \n \n \n \n \n \n \n \n 1e_1mnth\n \n \n \n \n \n \n \n \n \n 1e_3mnths\n \n \n \n \n \n \n \n \n \n 1e_6mnths\n \n \n \n \n \n \n \n \n \n 1e_other\n \n \n \n \n \n \n \n \n \n 1f_1mnth\n \n \n \n \n \n \n \n \n \n 1f_3mnths\n \n \n \n \n \n \n \n \n \n 1f_6mnths\n \n \n \n \n \n \n \n \n \n 1f_othmnth\n \n \n \n \n \n \n \n \n \n 1g_1mnth\n \n \n \n \n \n \n \n \n \n 1g_3mnths\n \n \n \n \n \n \n \n \n \n 1g_6mnths\n \n \n \n \n \n \n \n \n \n 1g_other\n \n \n \n \n \n \n \n \n \n 1h_1mnth\n \n \n \n \n \n \n \n \n \n 1h_3mnths\n \n \n \n \n \n \n \n \n \n 1h_6mnths\n \n \n \n \n \n \n \n \n \n 1h_other\n \n \n \n \n \n \n \n \n \n 1j_1mnth\n \n \n \n \n \n \n \n \n \n 1j_3mnths\n \n \n \n \n \n \n \n \n \n 1j_6mnths\n \n \n \n \n \n \n \n \n \n 1j_other\n \n \n \n \n \n \n \n \n \n 1k_1mnth\n \n \n \n \n \n \n \n \n \n 1k_3mnths\n \n \n \n \n \n \n \n \n \n 1k_6mnths\n \n \n \n \n \n \n \n \n \n 1k_other\n \n \n \n \n \n \n \n \n \n 1m_1mnth\n \n \n \n \n \n \n \n \n \n 1m_3mnths\n \n \n \n \n \n \n \n \n \n 1m_6mnths\n \n \n \n \n \n \n \n \n \n 1m_other\n \n \n \n \n \n \n \n \n \n 1n_1mnth\n \n \n \n \n \n \n \n \n \n 1n_3mnths\n \n \n \n \n \n \n \n \n \n 1n_6mnths\n \n \n \n \n \n \n \n \n \n 1n_other\n \n \n \n \n \n \n \n \n \n 1p_1mnth\n \n \n \n \n \n \n \n \n \n 1p_3mnths\n \n \n \n \n \n \n \n \n \n 1p_6mnths\n \n \n \n \n \n \n \n \n \n 1p_other\n \n \n \n \n \n \n \n \n \n 1q_1mnth\n \n \n \n \n \n \n \n \n \n 1q_3mnths\n \n \n \n \n \n \n \n \n \n 1q_6mnths\n \n \n \n \n \n \n \n \n \n 1q_other\n \n \n \n \n \n \n \n \n \n other_1mnt\n \n \n \n \n \n \n \n \n \n other_3mnt\n \n \n \n \n \n \n \n \n \n other_6mnt\n \n \n \n \n \n \n \n \n \n other_othe\n \n \n \n \n \n \n \n \n \n','2020-06-05 15:51:49',4,'2021-01-27 14:00:34',4,0,NULL,NULL,NULL,'48bdf3d1-3a1a-46b1-a53a-7db8f1a24781'),(755,'Children ARV Regimen_2ndLine 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 Data Set\n \n 2020-06-06 16:40:08 UTC\n \n 2020-06-06 17:59: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 755\n \n \n DM_Weight\n \n \n \n \n \n \n \n \n 5a10to13.9\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_Weight\n 10to13.9kg\n \n \n \n \n \n 5a14to19.9\n \n \n \n \n DM_Weight\n 14to19.9kg\n \n \n \n \n \n 5a20to24.9\n \n \n \n \n DM_Weight\n 20to24.9kg\n \n \n \n \n \n 5a25to34.9\n \n \n \n \n DM_Weight\n 25to34.9kg\n \n \n \n \n \n 5a3to3.9\n \n \n \n \n DM_Weight\n 03to3.9kg\n \n \n \n \n \n 5a4to5.9\n \n \n \n \n DM_Weight\n 04to5.9kg\n \n \n \n \n \n 5a6to9.9\n \n \n \n \n DM_Weight\n 06to9.9kg\n \n \n \n \n \n 5b10to13.9\n \n \n \n \n \n \n \n \n \n 5b14to19.9\n \n \n \n \n \n \n 5b20to24.9\n \n \n \n \n \n \n 5b25to34.9\n \n \n \n \n \n \n 5b3to3.9\n \n \n \n \n \n \n 5b4to5.9\n \n \n \n \n \n \n 5b6to9.9\n \n \n \n \n \n \n 5c10to13.9\n \n \n \n \n \n \n \n \n \n 5c14to19.9\n \n \n \n \n \n \n 5c20to24.9\n \n \n \n \n \n \n 5c25to34.9\n \n \n \n \n \n \n 5c3to3.9\n \n \n \n \n \n \n 5c4to5.9\n \n \n \n \n \n \n 5c6to9.9\n \n \n \n \n \n \n 5d10to13.9\n \n \n \n \n \n \n \n \n \n 5d14to19.9\n \n \n \n \n \n \n 5d20to24.9\n \n \n \n \n \n \n 5d25to34.9\n \n \n \n \n \n \n 5d3to3.9\n \n \n \n \n \n \n 5d4to5.9\n \n \n \n \n \n \n 5d6to9.9\n \n \n \n \n \n \n 5e10to13.9\n \n \n \n \n \n \n \n \n \n 5e14to19.9\n \n \n \n \n \n \n 5e20to24.9\n \n \n \n \n \n \n 5e25to34.9\n \n \n \n \n \n \n 5e3to3.9\n \n \n \n \n \n \n 5e4to5.9\n \n \n \n \n \n \n 5e6to9.9\n \n \n \n \n \n \n 5f10to13.9\n \n \n \n \n \n \n \n \n \n 5f14to19.9\n \n \n \n \n \n \n 5f20to24.9\n \n \n \n \n \n \n 5f25to34.9\n \n \n \n \n \n \n 5f3to3.9\n \n \n \n \n \n \n 5f4to5.9\n \n \n \n \n \n \n 5f6to9.9\n \n \n \n \n \n \n 5g10to13.9\n \n \n \n \n \n \n \n \n \n 5g14to19.9\n \n \n \n \n \n \n 5g20to24.9\n \n \n \n \n \n \n 5g25to34.9\n \n \n \n \n \n \n 5g3to3.9\n \n \n \n \n \n \n 5g4to5.9\n \n \n \n \n \n \n 5g6to9.9\n \n \n \n \n \n \n 5h10to13.9\n \n \n \n \n \n \n \n \n \n 5h14to19.9\n \n \n \n \n \n \n 5h20to24.9\n \n \n \n \n \n \n 5h25to34.9\n \n \n \n \n \n \n 5h3to3.9\n \n \n \n \n \n \n 5h4to5.9\n \n \n \n \n \n \n 5h6to9.9\n \n \n \n \n \n \n','2020-06-06 18:40:08',4,'2020-06-06 19:59:56',4,0,NULL,NULL,NULL,'b544b920-9355-4cde-91ef-1abce8a0666c'),(756,'Clients given CTX in the month','Clients given CTX in the month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given CTX in the month\n Clients given CTX in the month\n \n 2020-06-06 17:51:03 UTC\n \n 2020-06-06 17:52: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 756\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-06 19:51:03',4,'2020-06-06 19:52:29',4,0,NULL,NULL,NULL,'9227d423-f843-4299-866e-c0ef068a8faa'),(758,'Children ARV Regimen_3rdLine 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 Data Set\n \n 2020-06-06 18:10:43 UTC\n \n 2020-06-08 08:32: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 758\n \n \n DM_Weight\n \n \n \n \n \n \n \n \n 6a10to13.9\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_Weight\n 10to13.9kg\n \n \n \n \n \n 6a14to19.9\n \n \n \n \n DM_Weight\n 14to19.9kg\n \n \n \n \n \n 6a20to24.9\n \n \n \n \n DM_Weight\n 20to24.9kg\n \n \n \n \n \n 6a25to34.9\n \n \n \n \n DM_Weight\n 25to34.9kg\n \n \n \n \n \n 6a3to3.9\n \n \n \n \n DM_Weight\n 03to3.9kg\n \n \n \n \n \n 6a4to5.9\n \n \n \n \n DM_Weight\n 04to5.9kg\n \n \n \n \n \n 6a6to9.9\n \n \n \n \n DM_Weight\n 06to9.9kg\n \n \n \n \n \n 6b10to13.9\n \n \n \n \n \n \n \n \n \n 6b14to19.9\n \n \n \n \n \n \n 6b20to24.9\n \n \n \n \n \n \n 6b25to34.9\n \n \n \n \n \n \n 6b3to3.9\n \n \n \n \n \n \n 6b4to5.9\n \n \n \n \n \n \n 6b6to9.9\n \n \n \n \n \n \n 6c10to13.9\n \n \n \n \n \n \n \n \n \n 6c14to19.9\n \n \n \n \n \n \n 6c20to24.9\n \n \n \n \n \n \n 6c25to34.9\n \n \n \n \n \n \n 6c3to3.9\n \n \n \n \n \n \n 6c4to5.9\n \n \n \n \n \n \n 6c6to9.9\n \n \n \n \n \n \n 6d10to13.9\n \n \n \n \n \n \n \n \n \n 6d14to19.9\n \n \n \n \n \n \n 6d20to24.9\n \n \n \n \n \n \n 6d25to34.9\n \n \n \n \n \n \n 6d3to3.9\n \n \n \n \n \n \n 6d4to5.9\n \n \n \n \n \n \n 6d6to9.9\n \n \n \n \n \n \n 6e10to13.9\n \n \n \n \n \n \n \n \n \n 6e14to19.9\n \n \n \n \n \n \n 6e20to24.9\n \n \n \n \n \n \n 6e25to34.9\n \n \n \n \n \n \n 6e3to3.9\n \n \n \n \n \n \n 6e4to5.9\n \n \n \n \n \n \n 6e6to9.9\n \n \n \n \n \n \n 6f10to13.9\n \n \n \n \n \n \n \n \n \n 6f14to19.9\n \n \n \n \n \n \n 6f20to24.9\n \n \n \n \n \n \n 6f25to34.9\n \n \n \n \n \n \n 6f3to3.9\n \n \n \n \n \n \n 6f4to5.9\n \n \n \n \n \n \n 6f6to9.9\n \n \n \n \n \n \n','2020-06-06 20:10:43',4,'2020-06-08 10:32:22',4,0,NULL,NULL,NULL,'6e3a006d-98ce-4042-9850-7ba6ccfadebe'),(759,'2020_NUTRITIONAL SUPPLEMENT','new dataset NUTRITIONAL SUPPLEMENT','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_NUTRITIONAL SUPPLEMENT\n new dataset NUTRITIONAL SUPPLEMENT\n \n 2020-06-06 18:19:59 UTC\n \n 2020-06-06 18:20: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 759\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','2020-06-06 20:19:59',4,'2020-06-06 20:20:03',4,0,NULL,NULL,NULL,'bb75a854-ddeb-4ce5-b822-f76dd8bf22ad'),(760,'2020_NUTRITIONAL SUPPLEMENT Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_NUTRITIONAL SUPPLEMENT Data Set\n \n 2020-06-06 18:20:03 UTC\n \n 2020-06-08 10:00: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 760\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 F100FAdult\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 Adults\n \n \n \n \n \n F100FChild\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n F100MAdult\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Adults\n \n \n \n \n \n F100MChild\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n F75FAdult\n \n \n \n \n \n \n \n \n \n F75FChild\n \n \n \n \n \n \n F75MAdult\n \n \n \n \n \n \n F75MChild\n \n \n \n \n \n \n OtherFAdul\n \n \n \n \n \n \n \n \n \n OtherFChil\n \n \n \n \n \n \n OtherMAdul\n \n \n \n \n \n \n OtherMChil\n \n \n \n \n \n \n PlumpFAdul\n \n \n \n \n \n \n \n \n \n PlumpFChil\n \n \n \n \n \n \n PlumpMAdul\n \n \n \n \n \n \n PlumpMChil\n \n \n \n \n \n \n cereal-F14\n \n \n \n \n \n \n \n \n \n cereal_F15\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 15+yrs\n \n \n \n \n \n cereal-M14\n \n \n \n \n \n \n cereal_M15\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 15+yrs\n \n \n \n \n \n','2020-06-06 20:20:03',4,'2020-06-08 12:00:54',4,0,NULL,NULL,NULL,'acc0e9d9-fe35-4d6d-8707-818221deeaa9'),(761,'Plumpy Nut given in the month','Plumpy Nut given in the month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Plumpy Nut given in the month\n Plumpy Nut given in the month\n \n 2020-06-06 18:30:00 UTC\n \n 2020-06-06 18:30: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 761\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-06 20:30:00',4,'2020-06-06 20:30:55',4,0,NULL,NULL,NULL,'1a8809c1-0866-4b11-8ed9-2ca4fc02154e'),(762,'F100 given in the month','F100 given in the month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n F100 given in the month\n F100 given in the month\n \n 2020-06-06 18:32:13 UTC\n \n 2020-06-06 18:33: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 762\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-06 20:32:13',4,'2020-06-06 20:33:54',4,0,NULL,NULL,NULL,'5d68b260-ac27-417d-b075-27c258ed6e5d'),(763,'F75 given in the month','F75 given in the month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n F75 given in the month\n F75 given in the month\n \n 2020-06-06 18:34:41 UTC\n \n 2020-06-06 18: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 763\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-06 20:34:41',4,'2020-06-06 20:35:51',4,0,NULL,NULL,NULL,'f72d3c94-b272-489a-af95-c198ac632230'),(764,'Other Nutritional Supplement given in the month','Other Nutritional Supplement given in the month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Other Nutritional Supplement given in the month\n Other Nutritional Supplement given in the month\n \n 2020-06-06 18:37:18 UTC\n \n 2020-06-06 18:38: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 764\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-06 20:37:18',4,'2020-06-06 20:38:33',4,0,NULL,NULL,NULL,'49f802d9-a927-432f-9ecc-5320277583a1'),(765,'Given Super Cereal in the month','super cereal','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Given Super Cereal in the month\n super cereal\n \n 2020-06-08 09:14:51 UTC\n \n 2020-07-07 10:18: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 765\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand obs_datetime BETWEEN :startDate AND :endDate \nand concept_id = 4167 and value_coded = 4815\n','2020-06-08 09:14:51',4,'2020-07-07 10:18:22',4,0,NULL,NULL,NULL,'7e88e4d8-d827-49ba-85ce-942847494e02'),(766,'Given Super Cereal in the month','super cereal','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Given Super Cereal in the month\n super cereal\n \n 2020-06-08 09:16:05 UTC\n \n 2020-06-08 09:16: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 766\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-06-08 11:16:05',4,'2020-06-08 11:16:54',4,0,NULL,NULL,NULL,'7873e38f-7b02-46fc-8002-a0e6fcc7bde8'),(768,'testing Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n testing Data Set\n \n 2020-06-16 09:29:58 UTC\n \n 2020-06-16 09:35: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 768\n \n \n DM_Weight\n \n \n \n \n \n \n \n \n 1\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_Weight\n 03to3.9kg\n \n \n \n \n \n 2\n \n \n \n \n DM_Weight\n 06to9.9kg\n \n \n \n \n \n 3\n \n \n \n \n DM_Weight\n 10to13.9kg\n \n \n \n \n \n 4\n \n \n \n \n DM_Weight\n 14to19.9kg\n \n \n \n \n \n 5\n \n \n \n \n DM_Weight\n 20to24.9kg\n \n \n \n \n \n 6\n \n \n \n \n DM_Weight\n 25to34.9kg\n \n \n \n \n \n','2020-06-16 09:29:58',4,'2020-06-16 09:35:38',4,0,NULL,NULL,NULL,'bf5ad6aa-84e3-4553-8feb-3c3f5a6b7270'),(769,'Clients enrolled this month','Clients enrolled this month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients enrolled this month\n Clients enrolled this month\n \n 2020-06-19 08:31:52 UTC\n \n 2022-04-26 14:50: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 769\n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n -- Retesting Results Pos \n INNER JOIN person ON person.person_id = o.person_id \n where o.concept_id = 4817 and o.value_coded = 1738 \n AND o.voided = 0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND o.person_id in( \n select distinct os.person_id \n from obs os \n -- Not Linked to Care \n where os.concept_id = 4239 and os.value_coded = 2147 \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','2020-06-19 08:31:52',4,'2022-04-26 14:50:16',4,0,NULL,NULL,NULL,'7037562b-4e82-493e-8858-78e0d5d8fbbf'),(770,'Clients ever enrolled on PrE ART','Clients ever enrolled on care','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients ever enrolled on PrE ART\n Clients ever enrolled on care\n \n 2020-06-19 08:35:31 UTC\n \n 2022-04-27 09:49: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 770\n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n -- Retesting Results Positive \n INNER JOIN person ON person.person_id = o.person_id \n where o.concept_id = 4817 and o.value_coded = 1738 \n AND o.voided = 0 \n AND o.person_id in( \n select distinct os.person_id \n from obs os \n -- Not Linked to Care \n where os.concept_id = 4239 and os.value_coded = 2147 \n and os.voided = 0 \n ) \n AND o.person_id not in ( \n -- Current period Pre-ART \n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n -- Retesting Results Pos \n INNER JOIN person ON person.person_id = o.person_id \n where o.concept_id = 4817 and o.value_coded = 1738 \n AND o.voided = 0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND o.person_id in( \n select distinct os.person_id \n from obs os \n -- Not Linked to Care \n where os.concept_id = 4239 and os.value_coded = 2147 \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 \n )\n','2020-06-19 08:35:31',4,'2022-04-27 09:49:54',4,0,NULL,NULL,NULL,'ca1c2a0a-48f5-4370-b46a-2678e49bc163'),(771,'ART and Pre ART Seen this month','ART and Pre ART Seen this month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART and Pre ART Seen this month\n ART and Pre ART Seen this month\n \n 2020-06-19 08:43:33 UTC\n \n 2022-07-25 14:49: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 771\n select distinct person_id \nfrom \n((select distinct o.person_id \nfrom obs o \n-- CLIENTS PHYSICALLY SEEN FOR ART \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id AND person.voided = 0 \n WHERE o.concept_id = 3843 AND o.value_coded = 3842 \n AND MONTH(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND o.voided = 0 \n ) \n \nUNION \n \n( \n-- PreART \nselect distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n -- Retesting Results Pos \n INNER JOIN person ON person.person_id = o.person_id \n where o.concept_id = 4817 and o.value_coded = 1738 \n AND o.voided = 0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND o.person_id in( \n select distinct os.person_id \n from obs os \n -- Not Linked to Care \n where os.concept_id = 4239 and os.value_coded = 2147 \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))AS Seen_and_PreART\n','2020-06-19 08:43:33',4,'2022-07-25 14:49:01',4,0,NULL,NULL,NULL,'05ced471-b115-479a-976c-318595d37af4'),(772,'ART and Pre ART Screened this month','screened','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART and Pre ART Screened this month\n screened\n \n 2020-06-19 09:06:15 UTC\n \n 2022-07-25 15:24: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 772\n select distinct id \nfrom \n( \n(select distinct o.person_id as id \nfrom obs o \n-- CLIENTS PHYSICALLY SEEN FOR ART \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id AND person.voided = 0 \n WHERE o.concept_id = 3843 AND o.value_coded = 3842 \n AND MONTH(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND o.voided = 0 \n AND (o.location_id =:location or parent_location =:location) \n AND o.person_id in ( \n -- TB Screening \n select distinct os.person_id from obs os \n where os.concept_id = 3710 \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 \nUNION \n \n(select HTS_TB_Screening.person_id \nfrom \n(select B.person_id \n from obs B \n inner join location l on B.location_id = l.location_id \n INNER JOIN person ON person.person_id = B.person_id AND person.voided = 0 \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n -- HTS Form \n from obs where concept_id = 2386 \n and obs_datetime <= cast(:endDate as date) \n AND MONTH(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(obs_datetime) = YEAR(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 -- TB Screening \n where concept_id = 2294 and value_coded = 2146 \n and A.observation_id = B.obs_group_id \n and B.voided = 0 \n group by B.person_id) as HTS_TB_Screening \n inner join \n -- and A.person_id in ( \n ( \n -- PREART Clients \n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n -- Retesting Results Pos \n INNER JOIN person ON person.person_id = o.person_id \n where o.concept_id = 4817 and o.value_coded = 1738 \n AND o.voided = 0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND o.person_id in( \n select distinct os.person_id \n from obs os \n -- Not Linked to Care \n where os.concept_id = 4239 and os.value_coded = 2147 \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 ) Pre_ART \n on HTS_TB_Screening.person_id = Pre_ART.person_id \n ))TB_Screening_ART_and_PreART\n','2020-06-19 09:06:15',4,'2022-07-25 15:24:46',4,0,NULL,NULL,NULL,'71bce2a2-eb67-4815-b88a-27b4cd6c99ba'),(773,'Presumptive TB cases this month','Presumptive TB cases this month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Presumptive TB cases this month\n Presumptive TB cases this month\n \n 2020-06-19 09:10:24 UTC\n \n 2020-06-19 09:11: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 773\n select distinct o.person_id \nfrom obs o \n-- CLIENTS SEEN FOR ART \n inner join location l on o.location_id = l.location_id \n AND o.concept_id = 3843 AND o.value_coded in (3841,3842) \n AND MONTH(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND o.voided = 0 \n INNER JOIN person ON person.person_id = o.person_id AND person.voided = 0 \n WHERE (o.location_id =:location or parent_location =:location) \nand o.person_id in ( \n select person_id from obs \n where concept_id = 2223 \n ) \n \nand o.person_id in ( \n select person_id from obs \n where concept_id = 3710 and value_coded = 1876 \n AND MONTH(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n )\n','2020-06-19 09:10:24',4,'2020-06-19 09:11:43',4,0,NULL,NULL,NULL,'8a81c8cf-900c-4465-a136-5aba898d64d4'),(774,'Presumptive TB cases diagnosed with TB','diagnosed with TB','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Presumptive TB cases diagnosed with TB\n diagnosed with TB\n \n 2020-06-23 09:51:11 UTC\n \n 2020-06-23 09:54: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 774\n select person_id from obs \n -- genexpert \n where concept_id = 3787 and value_coded in (3816,3817) \n AND MONTH(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n -- line probe \n UNION \n select person_id from obs \n where concept_id = 3805 and value_coded in (1738) \n AND MONTH(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n UNION \n -- phenotypic \n select person_id from obs \n where concept_id = 3840 and value_coded in (3837,3838,3839) \n AND MONTH(obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(obs_datetime) = YEAR(CAST(:endDate AS DATE))\n','2020-06-23 09:51:11',4,'2020-06-23 09:54:51',4,0,NULL,NULL,NULL,'4d3236b4-cfb1-47cd-b616-9378de1a8d70'),(775,'Diagnosed with TB and started treatment this month','started TB this month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Diagnosed with TB and started treatment this month\n started TB this month\n \n 2020-06-23 09:58:58 UTC\n \n 2020-06-23 09: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 775\n select person_id from obs \nwhere concept_id = 2237 \nAND MONTH(value_datetime) = MONTH(CAST(:endDate AS DATE)) \nAND YEAR(value_datetime) = YEAR(CAST(:endDate AS DATE))\n','2020-06-23 09:58:58',4,'2020-06-23 09:59:24',4,0,NULL,NULL,NULL,'59423bc1-bdc8-467a-ad52-32e51434cfc9'),(776,'client_arv_1f','Clients given 1f regimen during reporting period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n client_arv_1f\n Clients given 1f regimen during reporting period\n \n 2020-07-18 19:58:37 UTC\n \n','2020-07-18 19:58:37',4,NULL,NULL,0,NULL,NULL,NULL,'134439b8-8727-4186-a4d1-07d8eb8df1ec'),(777,'ARV Regimen 1f TDF-3TC-EFV SQL','Clients given 1f regimen during reporting period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ARV Regimen 1f TDF-3TC-EFV SQL\n Clients given 1f regimen during reporting period\n \n 2020-07-18 19:58:37 UTC\n \n 2020-07-19 01:56:13 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 777\n select o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere o.concept_id = 2250 and o.value_coded = 2207 \n and o.location_id =:location or parent_location =:location \n and o.obs_datetime between :startDate and :endDate \n and o.voided = 0 \n and o.person_id in ( \n select oss.person_id \n from obs oss \n where oss.obs_datetime BETWEEN :startDate AND :endDate \n and oss.concept_id = 4174 and oss.value_coded in (4175, 4243) \n )\n','2020-07-18 19:58:37',4,'2020-07-19 01:56:13',4,0,NULL,NULL,NULL,'48b7c7f2-0b24-4fcb-936a-3161ccb96809'),(778,'Clients Initiated SQL','Client who were newly initiated on ART during period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients Initiated SQL\n Client who were newly initiated on ART during period\n \n 2020-07-18 20:31:33 UTC\n \n 2020-07-18 20:39: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 778\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere o.concept_id = 2249 \n and date(o.value_datetime) between cast(:startDate as date) and cast(:endDate as date) \n and o.location_id = :location or parent_location = :location \n and o.voided = 0 \n and o.person_id not in ( \n select os.person_id from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n and os.obs_datetime between cast(:startDate as date) and cast(:endDate as date) \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 \n ) \n and o.person_id not in ( \n select os.person_id \n from obs os \n where os.concept_id = 4155 and os.value_coded = 2146 \n and os.obs_datetime between cast(:startDate as date) and cast(:endDate as date) \n )\n','2020-07-18 20:31:33',4,'2020-07-18 20:39:16',4,0,NULL,NULL,NULL,'58e7985e-69a0-4d49-846f-b9aff06675db'),(779,'CMP_ART Regimen 1month supply 1f','Active clients on ART given 1 month supply of 1f during the reporting period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1f\n Active clients on ART given 1 month supply of 1f during the reporting period\n \n 2020-07-19 01:31:05 UTC\n \n 2020-07-19 04: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 779\n Clients-newly-initiated-1f OR Clients-seen-given-1-month-supply-1f\n \n \n Clients-newly-initiated-1f\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 Clients-seen-given-1-month-supply-1f\n \n \n \n \n \n \n','2020-07-19 01:31:05',4,'2020-07-19 04:00:42',4,0,NULL,NULL,NULL,'1b85fc5a-285d-44ee-8d93-89823330461c'),(780,'CI07a: Adult 1st Line 1f=TDF-3TC-EFV 1month supply','Adults on 1st line 1f=TDF-3TC-EFV given 1month supply during the reporting period','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI07a: Adult 1st Line 1f=TDF-3TC-EFV 1month supply\n Adults on 1st line 1f=TDF-3TC-EFV given 1month supply during the reporting period\n \n 2020-07-19 01:41:26 UTC\n \n 2021-07-13 10:53: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 780\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-19 01:41:26',4,'2021-07-13 10:53:55',4,0,NULL,NULL,NULL,'266432b4-af8d-4c1f-9964-0e18df6a8ddb'),(781,'Clients seen given 1 month supply 1f','Clients seen for ART given 1 month supply of 1f regimen during period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1f\n Clients seen for ART given 1 month supply of 1f regimen during period\n \n 2020-07-19 03:54:29 UTC\n \n 2021-07-08 14:08:48 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 781\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2207)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-19 03:54:29',4,'2021-07-08 14:08:48',4,0,NULL,NULL,NULL,'aa28ce0b-63fd-424e-a559-32afafdf1bd4'),(782,'Clients given 3 months supply 1f','Clients seen given 3 months supply and those seen in previous months given 3 months supply for the reporting period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1f\n Clients seen given 3 months supply and those seen in previous months given 3 months supply for the reporting period\n \n 2020-07-19 04:12:20 UTC\n \n 2021-06-30 09:54:55 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 782\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2207)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-19 04:12:20',4,'2021-06-30 09:54:55',4,0,NULL,NULL,NULL,'08339268-81bc-4b91-860e-5fe9e69a96d9'),(783,'CMP_ART Regimen 3months supply 1f','Clients given 3 months supply of 1f regimen including Seen and Multi month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 3months supply 1f\n Clients given 3 months supply of 1f regimen including Seen and Multi month\n \n 2020-07-19 04:17:16 UTC\n \n 2020-07-19 04:18:45 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 783\n Clients-given-3-months-supply-1f\n \n \n Clients-given-3-months-supply-1f\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','2020-07-19 04:17:16',4,'2020-07-19 04:18:45',4,0,NULL,NULL,NULL,'3c34cfe7-e888-4dd5-8618-e0d0b3c0e7ec'),(784,'Clients given 6 months supply 1f','Clients seen given 6 months supply and those seen in previous months given 6 months supply for the reporting period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1f\n Clients seen given 6 months supply and those seen in previous months given 6 months supply for the reporting period\n \n 2020-07-19 04:31:40 UTC\n \n 2021-06-30 11: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 784\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2207)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-19 04:31:40',4,'2021-06-30 11:12:29',4,0,NULL,NULL,NULL,'a96d7239-75fc-49da-8fc2-e5de7f363b3a'),(785,'Clients given Other months MMD supply 1f','Clients seen in current month given 2, 4, 5 or 7+ months supply and those seen in previous months given 2, 4, 5 or 7+ months supply for the reporting period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1f\n Clients seen in current month given 2, 4, 5 or 7+ months supply and those seen in previous months given 2, 4, 5 or 7+ months supply for the reporting period\n \n 2020-07-19 04:43:12 UTC\n \n 2021-06-30 11:42:53 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 785\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2207)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-19 04:43:12',4,'2021-06-30 11:42:53',4,0,NULL,NULL,NULL,'769c1abe-1bbd-44ad-8151-48df3b0e7d28'); +INSERT INTO `serialized_object` VALUES (786,'CMP_ART Regimen 6months supply 1f','Clients given 6 months supply of 1f regimen including Seen and Multi month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 6months supply 1f\n Clients given 6 months supply of 1f regimen including Seen and Multi month\n \n 2020-07-19 04:46:50 UTC\n \n 2020-07-19 04:48:17 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 786\n Clients-given-6-months-supply-1f\n \n \n Clients-given-6-months-supply-1f\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','2020-07-19 04:46:50',4,'2020-07-19 04:48:17',4,0,NULL,NULL,NULL,'18e58639-4cfd-40bf-bf06-3599464b1473'),(787,'CMP_ART Regimen Other months MMD supply 1f','Clients given 2, 4 or 5 months supply of 1f regimen including Seen and Multi month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen Other months MMD supply 1f\n Clients given 2, 4 or 5 months supply of 1f regimen including Seen and Multi month\n \n 2020-07-19 04:49:08 UTC\n \n 2020-07-19 04:50:50 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 787\n Clients-given-Other-months-MMD-supply-1f\n \n \n Clients-given-Other-months-MMD-supply-1f\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','2020-07-19 04:49:08',4,'2020-07-19 04:50:50',4,0,NULL,NULL,NULL,'f95caefd-dc5f-4243-a75e-5e3e0b7911a0'),(788,'CI07b: Adult 1st Line 1f=TDF-3TC-EFV 3months supply','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI07b: Adult 1st Line 1f=TDF-3TC-EFV 3months supply\n \n \n 2020-07-19 06:18:10 UTC\n \n 2020-07-19 06:19:08 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 788\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-19 06:18:10',4,'2020-07-19 06:19:08',4,0,NULL,NULL,NULL,'780982cb-6a98-4775-8e76-9baa9d6b5f1b'),(789,'CI07c: Adult 1st Line 1f=TDF-3TC-EFV 6months supply','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI07c: Adult 1st Line 1f=TDF-3TC-EFV 6months supply\n \n \n 2020-07-19 06:20:27 UTC\n \n 2020-07-19 06:21:46 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 789\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-19 06:20:27',4,'2020-07-19 06:21:46',4,0,NULL,NULL,NULL,'e973976c-ca6a-4ac1-887a-2ebfe531a534'),(790,'CI07d: Adult 1st Line 1f=TDF-3TC-EFV Other (2, 4, 5 or 7+) MMD supply','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI07d: Adult 1st Line 1f=TDF-3TC-EFV Other (2, 4, 5 or 7+) MMD supply\n \n \n 2020-07-19 06:23:06 UTC\n \n 2020-07-21 01:48:17 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 790\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-19 06:23:06',4,'2020-07-21 01:48:17',4,0,NULL,NULL,NULL,'9ab8597a-486e-4d0f-ab75-7f113a29b08a'),(791,'Clients seen given 1 month supply 1c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1c\n \n \n 2020-07-20 03:19:19 UTC\n \n 2021-07-08 11:55:18 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 791\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2201)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:19:19',4,'2021-07-08 11:55:18',4,0,NULL,NULL,NULL,'af67b7bb-850e-4d7e-b736-07ccf3a76b09'),(792,'Clients given 3 months supply 1c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1c\n \n \n 2020-07-20 03:20:58 UTC\n \n 2021-06-30 09:51:24 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n endDateas\n \n java.util.Date\n true\n \n \n 792\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2201)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:20:58',4,'2021-06-30 09:51:24',4,0,NULL,NULL,NULL,'60b41494-8391-41e6-8f16-103bd95b4f44'),(793,'Clients given 6 months supply 1c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1c\n \n \n 2020-07-20 03:22:31 UTC\n \n 2021-06-30 11:05:32 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 793\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2201)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:22:31',4,'2021-06-30 11:05:32',4,0,NULL,NULL,NULL,'41a29f67-1b66-4614-86fb-d1f9a7f97bfb'),(794,'Clients given Other months MMD supply 1c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1c\n \n \n 2020-07-20 03:23:47 UTC\n \n 2021-06-30 11:37:55 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 794\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2201)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:23:47',4,'2021-06-30 11:37:55',4,0,NULL,NULL,NULL,'96c856a3-566e-4505-a448-160539293a28'),(795,'Clients seen given 1 month supply 1d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1d\n \n \n 2020-07-20 03:37:30 UTC\n \n 2021-07-08 11:57: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 795\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2203)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:37:30',4,'2021-07-08 11:57:56',4,0,NULL,NULL,NULL,'98353f43-868f-4509-ad15-37dc3adb0a1b'),(796,'Clients given 3 months supply 1d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1d\n \n \n 2020-07-20 03:39:17 UTC\n \n 2021-06-30 09:52:14 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 796\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2203)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:39:17',4,'2021-06-30 09:52:14',4,0,NULL,NULL,NULL,'069f81cf-1fa0-4367-83c8-0f3c20c42f85'),(797,'Clients given 6 months supply 1d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1d\n \n \n 2020-07-20 03:40:12 UTC\n \n 2021-06-30 11:07:24 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 797\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2203)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:40:12',4,'2021-06-30 11:07:24',4,0,NULL,NULL,NULL,'ea10a065-3af9-4102-a59b-5be824284852'),(798,'Clients given Other months MMD supply 1d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1d\n \n \n 2020-07-20 03:41:17 UTC\n \n 2021-06-30 11:41:47 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 798\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2203)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:41:17',4,'2021-06-30 11:41:47',4,0,NULL,NULL,NULL,'6c93540e-b083-41a9-9f17-a5ed6b921c72'),(799,'Clients seen given 1 month supply 1e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1e\n \n \n 2020-07-20 03:46:44 UTC\n \n 2021-07-08 11:58: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 799\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2205)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:46:44',4,'2021-07-08 11:58:20',4,0,NULL,NULL,NULL,'c7dd5c81-99f1-45fc-a84d-ec75465bd3d4'),(800,'Clients given 3 months supply 1e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1e\n \n \n 2020-07-20 03:47:32 UTC\n \n 2021-06-30 09:54:23 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 800\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2205)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:47:32',4,'2021-06-30 09:54:23',4,0,NULL,NULL,NULL,'e6b6c271-1dca-4432-bbaf-58d82c4f49da'),(801,'Clients given 6 months supply 1e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1e\n \n \n 2020-07-20 03:48:37 UTC\n \n 2021-06-30 11:11:57 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 801\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2205)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:48:37',4,'2021-06-30 11:11:57',4,0,NULL,NULL,NULL,'354b0335-23b3-48cc-8a95-c417fafcfc89'),(802,'Clients given Other months MMD supply 1e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1e\n \n \n 2020-07-20 03:49:41 UTC\n \n 2021-06-30 11:42:23 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 802\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2205)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:49:41',4,'2021-06-30 11:42:23',4,0,NULL,NULL,NULL,'e40f765b-16fd-4a32-b7a4-eede8841f1cf'),(803,'Clients seen given 1 month supply 1g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1g\n \n \n 2020-07-20 03:58:38 UTC\n \n 2021-07-08 14:09:31 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 803\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3672)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 03:58:38',4,'2021-07-08 14:09:31',4,0,NULL,NULL,NULL,'b3d8a75c-e786-4f83-8938-8af473c5953b'),(804,'Clients given 3 months supply 1g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1g\n \n \n 2020-07-20 04:00:16 UTC\n \n 2021-06-30 09:55:48 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 804\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3672)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:00:16',4,'2021-06-30 09:55:48',4,0,NULL,NULL,NULL,'ffc466dd-6ba0-4c8b-b843-200ea3d86bd2'),(805,'Clients given 6 months supply 1g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1g\n \n \n 2020-07-20 04:01:31 UTC\n \n 2021-06-30 11:14:32 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 805\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3672)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:01:31',4,'2021-06-30 11:14:32',4,0,NULL,NULL,NULL,'9062d6f9-de1a-4bd5-875c-6357ab622d92'),(806,'Clients given Other months MMD supply 1g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1g\n \n \n 2020-07-20 04:02:23 UTC\n \n 2021-06-30 11:43:38 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 806\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3672)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:02:23',4,'2021-06-30 11:43:38',4,0,NULL,NULL,NULL,'5e27d4a7-b843-4094-8f8e-c926f758e43a'),(807,'Clients seen given 1 month supply 1h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1h\n \n \n 2020-07-20 04:10:22 UTC\n \n 2021-07-08 14:10: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 807\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3673)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:10:22',4,'2021-07-08 14:10:03',4,0,NULL,NULL,NULL,'fe4a76e1-27ff-4dd1-b1e0-41906972b346'),(808,'Clients given 6 months supply 1h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1h\n \n \n 2020-07-20 04:12:36 UTC\n \n 2021-06-30 11:15:07 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 808\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3673)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:12:36',4,'2021-06-30 11:15:07',4,0,NULL,NULL,NULL,'04df1d42-9165-4fb9-bf72-5af4edeeb4b3'),(809,'Clients given 3 months supply 1h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1h\n \n \n 2020-07-20 04:13:53 UTC\n \n 2021-06-30 09:56:18 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 809\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3673)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:13:53',4,'2021-06-30 09:56:18',4,0,NULL,NULL,NULL,'b790398e-94da-443c-a2e6-f0d5a40b54c0'),(810,'Clients given Other months MMD supply 1h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1h\n \n \n 2020-07-20 04:17:17 UTC\n \n 2021-06-30 11:44:24 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 810\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3673)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:17:17',4,'2021-06-30 11:44:24',4,0,NULL,NULL,NULL,'d6cee7dc-26b3-47ee-9227-25aaf080d496'),(811,'Clients newly initiated 1j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1j\n \n \n 2020-07-20 04:25:32 UTC\n \n 2021-01-27 14:42:09 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 811\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4678 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 04:25:32',4,'2021-01-27 14:42:09',4,0,NULL,NULL,NULL,'9beae5ae-2e70-4911-9e5c-8b8472e9e035'),(812,'Clients seen given 1 month supply 1j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1j\n \n \n 2020-07-20 04:26:51 UTC\n \n 2021-07-08 11:06:54 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 812\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4678)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:26:51',4,'2021-07-08 11:06:54',4,0,NULL,NULL,NULL,'0be4efe7-801d-482d-ba8b-4d6b5fd33883'),(813,'Clients given 3 months supply 1j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1j\n \n \n 2020-07-20 04:28:15 UTC\n \n 2021-06-30 09:56:52 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 813\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4678)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:28:15',4,'2021-06-30 09:56:52',4,0,NULL,NULL,NULL,'15fad161-116e-42b3-b0a2-7649bce5addc'),(814,'Clients given 6 months supply 1j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1j\n \n \n 2020-07-20 04:29:15 UTC\n \n 2021-06-30 11:16:04 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 814\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4678)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:29:15',4,'2021-06-30 11:16:04',4,0,NULL,NULL,NULL,'23ae89c1-56ed-4bc5-9602-9d0d16b08c94'),(815,'Clients given Other months MMD supply 1j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1j\n \n \n 2020-07-20 04:30:02 UTC\n \n 2021-06-30 11:45:21 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 815\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4678)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:30:02',4,'2021-06-30 11:45:21',4,0,NULL,NULL,NULL,'ef251548-179f-46cf-9207-2cb47e47dbbc'),(816,'Clients newly initiated 1k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1k\n \n \n 2020-07-20 04:39:49 UTC\n \n 2021-01-27 14:43:48 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 816\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4679 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 04:39:49',4,'2021-01-27 14:43:48',4,0,NULL,NULL,NULL,'ffafa46e-8967-4ad9-9825-24337956bac5'),(817,'Clients seen given 1 month supply 1k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1k\n \n \n 2020-07-20 04:40:45 UTC\n \n 2021-07-08 14:11: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 817\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4679)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:40:45',4,'2021-07-08 14:11:07',4,0,NULL,NULL,NULL,'7685302a-4622-4230-be73-76868feec142'),(818,'Clients given 3 months supply 1k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1k\n \n \n 2020-07-20 04:42:09 UTC\n \n 2021-06-30 09:57:45 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 818\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4679)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:42:09',4,'2021-06-30 09:57:45',4,0,NULL,NULL,NULL,'196d200b-cd91-4bbd-acbb-4f016368cad8'),(819,'Clients given 6 months supply 1k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1k\n \n \n 2020-07-20 04:43:10 UTC\n \n 2021-06-30 11:16:48 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 819\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4679)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:43:10',4,'2021-06-30 11:16:48',4,0,NULL,NULL,NULL,'3fc19342-46e1-45af-94b5-e2c691cb69e4'),(820,'Clients given Other months MMD supply 1k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1k\n \n \n 2020-07-20 04:44:01 UTC\n \n 2021-06-30 11:46:02 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 820\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4679)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:44:01',4,'2021-06-30 11:46:02',4,0,NULL,NULL,NULL,'e6de45f1-6b8a-4436-ba97-b13059648def'),(821,'Clients newly initiated 1m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1m\n \n \n 2020-07-20 04:49:48 UTC\n \n 2021-01-27 14:44: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 821\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4680 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 04:49:48',4,'2021-01-27 14:44:29',4,0,NULL,NULL,NULL,'400c82ab-1ac9-4abe-af01-6eada8daf6e9'),(822,'Clients seen given 1 month supply 1m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1m\n \n \n 2020-07-20 04:50:41 UTC\n \n 2021-07-08 14:15: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 822\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4680)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:50:41',4,'2021-07-08 14:15:35',4,0,NULL,NULL,NULL,'9b8ae57c-2fef-42fd-bbad-b45c5e983226'),(823,'Clients given 3 months supply 1m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1m\n \n \n 2020-07-20 04:52:21 UTC\n \n 2021-06-30 09:58:16 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 823\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4680)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:52:21',4,'2021-06-30 09:58:16',4,0,NULL,NULL,NULL,'7dd2938b-6b42-45d4-a2cd-8a8624e1c42c'),(824,'Clients given 6 months supply 1m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1m\n \n \n 2020-07-20 04:52:59 UTC\n \n 2021-06-30 11:18:09 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 824\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4680)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:52:59',4,'2021-06-30 11:18:09',4,0,NULL,NULL,NULL,'bdd8854a-8e0d-4c16-8ccd-b2c0ac7e3fe7'),(825,'Clients given Other months MMD supply 1m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1m\n \n \n 2020-07-20 04:54:54 UTC\n \n 2021-06-30 11:46:37 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 825\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4680)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 04:54:54',4,'2021-06-30 11:46:37',4,0,NULL,NULL,NULL,'4ecbaa81-3f7c-46e5-834f-ddb6439039fc'),(826,'Clients newly initiated 1n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1n\n \n \n 2020-07-20 06:27:02 UTC\n \n 2021-01-27 14:47:42 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 826\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4681 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 06:27:02',4,'2021-01-27 14:47:42',4,0,NULL,NULL,NULL,'963f22d5-2068-4709-905b-3ec479ccde36'),(827,'Clients seen given 1 month supply 1n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1n\n \n \n 2020-07-20 06:29:10 UTC\n \n 2021-07-08 14:16:16 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 827\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4681)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:29:10',4,'2021-07-08 14:16:16',4,0,NULL,NULL,NULL,'2f27d810-0b99-43bb-818a-ac56ed6cc563'),(828,'Clients given 3 months supply 1n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1n\n \n \n 2020-07-20 06:30:01 UTC\n \n 2021-06-30 09:58:59 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 828\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4681)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:30:01',4,'2021-06-30 09:58:59',4,0,NULL,NULL,NULL,'16299f28-bb97-404c-992a-0ec5df3fd70e'),(829,'Clients given 6 months supply 1n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1n\n \n \n 2020-07-20 06:31:04 UTC\n \n 2021-06-30 11:20:58 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 829\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4681)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:31:04',4,'2021-06-30 11:20:58',4,0,NULL,NULL,NULL,'6978b1ca-2787-45ea-8552-0085b4948fdc'),(830,'Clients given Other months MMD supply 1n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1n\n \n \n 2020-07-20 06:31:57 UTC\n \n 2021-06-30 11:47:10 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 830\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4681)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:31:57',4,'2021-06-30 11:47:10',4,0,NULL,NULL,NULL,'db874a28-7767-4d91-8cd5-9e1dd5911ad6'),(831,'Clients newly initiated 1p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1p\n \n \n 2020-07-20 06:35:57 UTC\n \n 2021-01-27 14:48:48 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 831\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4682 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 06:35:57',4,'2021-01-27 14:48:48',4,0,NULL,NULL,NULL,'1ad60b6d-87fa-4d43-a8a6-3018aedfcd66'),(832,'Clients seen given 1 month supply 1p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1p\n \n \n 2020-07-20 06:36:55 UTC\n \n 2021-07-08 14:16: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 832\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4682)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:36:55',4,'2021-07-08 14:16:45',4,0,NULL,NULL,NULL,'173e906f-ba1c-43bb-9d48-f11d32ce0241'),(833,'Clients given 3 months supply 1p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1p\n \n \n 2020-07-20 06:38:16 UTC\n \n 2021-06-30 09:59:46 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 833\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4682)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:38:16',4,'2021-06-30 09:59:46',4,0,NULL,NULL,NULL,'64c658a4-cc2a-46b6-8831-5549e6d3e893'),(834,'Clients given 6 months supply 1p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1p\n \n \n 2020-07-20 06:39:07 UTC\n \n 2021-06-30 11:21:31 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 834\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4682)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:39:07',4,'2021-06-30 11:21:31',4,0,NULL,NULL,NULL,'753da82d-feaf-46d9-bcc5-f2b08f4bf1f7'),(835,'Clients given Other months MMD supply 1p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1p\n \n \n 2020-07-20 06:39:59 UTC\n \n 2021-06-30 11:48:00 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 835\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4682)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:39:59',4,'2021-06-30 11:48:00',4,0,NULL,NULL,NULL,'0f780026-4b19-47c2-b88a-f103b85b8493'),(836,'Clients newly initiated 1q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 1q\n \n \n 2020-07-20 06:43:42 UTC\n \n 2021-01-27 14:50:00 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 836\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4683 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 06:43:42',4,'2021-01-27 14:50:00',4,0,NULL,NULL,NULL,'45f73eeb-68d7-442a-85b1-a2a3e5eacf79'),(837,'Clients seen given 1 month supply 1q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 1q\n \n \n 2020-07-20 06:44:27 UTC\n \n 2021-07-08 14:17:36 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 837\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4683)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:44:27',4,'2021-07-08 14:17:36',4,0,NULL,NULL,NULL,'16822ce4-ed25-45cf-93e1-9d4de906c4c6'),(838,'Clients given 3 months supply 1q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 1q\n \n \n 2020-07-20 06:45:34 UTC\n \n 2021-06-30 10:00:22 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 838\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4683)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:45:34',4,'2021-06-30 10:00:22',4,0,NULL,NULL,NULL,'1ed9b3ff-13e6-49eb-a21b-a3c588489a1b'),(839,'Clients given 6 months supply 1q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 1q\n \n \n 2020-07-20 06:46:18 UTC\n \n 2021-06-30 11:23:53 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 839\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4683)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:46:18',4,'2021-06-30 11:23:53',4,0,NULL,NULL,NULL,'ebb33bdb-909b-4b87-a22e-b124d146291a'),(840,'Clients given Other months MMD supply 1q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 1q\n \n \n 2020-07-20 06:47:11 UTC\n \n 2021-06-30 11:48:27 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 840\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4683)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:47:11',4,'2021-06-30 11:48:27',4,0,NULL,NULL,NULL,'ae410b11-acaa-425d-a309-7eb491cfa3eb'),(841,'Clients seen given 1 month supply 2c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2c\n \n \n 2020-07-20 06:53:36 UTC\n \n 2021-07-13 14:12: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 841\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2210)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:53:36',4,'2021-07-13 14:12:15',4,0,NULL,NULL,NULL,'c1f9e099-143c-4dd2-bfe0-8946fc5d148e'),(842,'Clients given 3 months supply 2c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2c\n \n \n 2020-07-20 06:54:57 UTC\n \n 2021-07-08 15:15:31 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 842\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 2210)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:54:57',4,'2021-07-08 15:15:31',4,0,NULL,NULL,NULL,'eca79239-2660-4146-ab21-53161a156d97'),(843,'Clients given 6 months supply 2c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2c\n \n \n 2020-07-20 06:55:39 UTC\n \n 2021-01-26 18:53:01 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 843\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 2210) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 2210) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 2210) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 2210) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 2210) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 2210) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 2210 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 06:55:39',4,'2021-01-26 18:53:01',4,0,NULL,NULL,NULL,'f408c2e1-4417-427b-ac7d-5bb0bce3656c'),(844,'Clients given Other months MMD supply 2c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2c\n \n \n 2020-07-20 06:57:41 UTC\n \n 2021-07-24 21:30:54 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 844\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2210)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 06:57:41',4,'2021-07-24 21:30:54',4,0,NULL,NULL,NULL,'986a2393-6ee9-4072-ae1d-04fd7b892a0d'),(845,'Clients seen given 1 month supply 2d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2d\n \n \n 2020-07-20 10:42:25 UTC\n \n 2021-07-13 14:14: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 845\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2209)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 10:42:25',4,'2021-07-13 14:14:04',4,0,NULL,NULL,NULL,'50d1da47-5c78-46f0-81dc-11c7eb0a2e60'),(846,'Clients given 3 months supply 2d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2d\n \n \n 2020-07-20 10:43:36 UTC\n \n 2021-07-14 08:13:38 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 846\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 2209)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 10:43:36',4,'2021-07-14 08:13:38',4,0,NULL,NULL,NULL,'2ab0d6c5-13ff-453d-98f2-c02b1eb59c41'),(847,'Clients given 6 months supply 2d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2d\n \n \n 2020-07-20 10:44:21 UTC\n \n 2021-01-26 18:57:10 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 847\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 2209) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 2209) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 2209) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 2209) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 2209) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 2209) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 2209 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 10:44:21',4,'2021-01-26 18:57:10',4,0,NULL,NULL,NULL,'99f90724-28b7-45c7-a73d-63d4d8f88dc0'),(848,'Clients given Other months MMD supply 2d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2d\n \n \n 2020-07-20 10:45:14 UTC\n \n 2021-07-24 21:31:27 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 848\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2209)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 10:45:14',4,'2021-07-24 21:31:27',4,0,NULL,NULL,NULL,'255083b1-80a9-41dd-8664-be91528a3d37'),(850,'Clients seen given 1 month supply 2e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2e\n \n \n 2020-07-20 12:24:17 UTC\n \n 2021-07-13 14:15:00 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 850\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3674)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 12:24:17',4,'2021-07-13 14:15:00',4,0,NULL,NULL,NULL,'226382c4-5c57-442d-ac94-dad96849df3b'),(851,'Clients given 3 months supply 2e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2e\n \n \n 2020-07-20 12:52:35 UTC\n \n 2021-07-14 08:14:33 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 851\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 3674)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 12:52:35',4,'2021-07-14 08:14:33',4,0,NULL,NULL,NULL,'69f7f4ee-f01a-433e-a758-8f616a3ff039'),(852,'Clients given 6 months supply 2e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2e\n \n \n 2020-07-20 12:54:03 UTC\n \n 2021-01-26 18:59:19 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 852\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3674) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 3674) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3674) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3674) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3674) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3674) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 3674 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 12:54:03',4,'2021-01-26 18:59:19',4,0,NULL,NULL,NULL,'cb6971ec-8888-4435-ae57-a6179afcdcb4'),(853,'Clients given Other months MMD supply 2e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2e\n \n \n 2020-07-20 12:54:40 UTC\n \n 2021-07-24 21:32:50 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 853\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3674)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 12:54:40',4,'2021-07-24 21:32:50',4,0,NULL,NULL,NULL,'204bc8e1-d480-469b-8e87-eeaf1842258b'),(854,'Clients seen given 1 month supply 2f','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2f\n \n \n 2020-07-20 13:01:49 UTC\n \n 2021-07-13 14:15:59 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 854\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3675)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:01:49',4,'2021-07-13 14:15:59',4,0,NULL,NULL,NULL,'c7c374df-995a-4c8e-b417-e9c71cd3798d'),(855,'Clients given 3 months supply 2f','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2f\n \n \n 2020-07-20 13:02:35 UTC\n \n 2021-07-14 08:15:05 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 855\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 3675)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:02:35',4,'2021-07-14 08:15:05',4,0,NULL,NULL,NULL,'15ced29c-f6a5-4742-beca-0f6367a97bca'),(856,'Clients given 6 months supply 2f','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2f\n \n \n 2020-07-20 13:03:51 UTC\n \n 2021-01-26 19:00:50 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 856\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3675) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 3675) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3675) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3675) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3675) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3675) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 3675 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 13:03:51',4,'2021-01-26 19:00:50',4,0,NULL,NULL,NULL,'565bb065-69d1-4c09-9381-78b51e2f53bc'); +INSERT INTO `serialized_object` VALUES (858,'Clients given Other months MMD supply 2f','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2f\n \n \n 2020-07-20 13:07:55 UTC\n \n 2021-07-24 21:33:24 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 858\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3675)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:07:55',4,'2021-07-24 21:33:24',4,0,NULL,NULL,NULL,'c2aaab49-9a28-4ac1-a9e7-58f87bcb3c00'),(859,'Clients seen given 1 month supply 2g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2g\n \n \n 2020-07-20 13:30:40 UTC\n \n 2021-07-13 14:16:33 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 859\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3676)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:30:40',4,'2021-07-13 14:16:33',4,0,NULL,NULL,NULL,'e09c5f28-85e5-4df9-970d-4e771a0a12fa'),(860,'Clients given 3 months supply 2g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2g\n \n \n 2020-07-20 13:31:29 UTC\n \n 2021-07-14 08:15:34 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 860\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 3676)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:31:29',4,'2021-07-14 08:15:34',4,0,NULL,NULL,NULL,'7a0140a1-1dac-4d2c-b23b-54bdbcdc3cfd'),(861,'Clients given 6 months supply 2g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2g\n \n \n 2020-07-20 13:32:15 UTC\n \n 2021-01-26 19:02:43 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 861\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3676) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 3676) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3676) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3676) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3676) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3676) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 3676 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 13:32:15',4,'2021-01-26 19:02:43',4,0,NULL,NULL,NULL,'563531db-dcac-42ed-aed1-6942a8d6adf0'),(862,'Clients given Other months MMD supply 2g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2g\n \n \n 2020-07-20 13:34:03 UTC\n \n 2021-07-24 21:33:49 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 862\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3676)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:34:03',4,'2021-07-24 21:33:49',4,0,NULL,NULL,NULL,'f4085fa1-d19d-4654-ab8a-5030eed896a7'),(863,'Clients seen given 1 month supply 2h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2h\n \n \n 2020-07-20 13:45:23 UTC\n \n 2021-07-13 14:17:29 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 863\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3677)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:45:23',4,'2021-07-13 14:17:29',4,0,NULL,NULL,NULL,'b4786a8b-fccd-4fe1-964f-70034909846f'),(864,'Clients given 3 months supply 2h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2h\n \n \n 2020-07-20 13:47:29 UTC\n \n 2021-07-14 08:16:40 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 864\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 3677)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:47:29',4,'2021-07-14 08:16:40',4,0,NULL,NULL,NULL,'4a6f7a2a-2166-487e-9add-7655727277ad'),(865,'Clients given 6 months supply 2h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2h\n \n \n 2020-07-20 13:48:11 UTC\n \n 2021-01-26 19:04:40 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 865\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3677) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 3677) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3677) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3677) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3677) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3677) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 3677 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 13:48:11',4,'2021-01-26 19:04:40',4,0,NULL,NULL,NULL,'2c4a733e-3851-4008-93d2-7e74cfec135b'),(866,'Clients given Other months MMD supply 2h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2h\n \n \n 2020-07-20 13:50:21 UTC\n \n 2021-07-24 21:34:22 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 866\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3677)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 13:50:21',4,'2021-07-24 21:34:22',4,0,NULL,NULL,NULL,'aebf1799-6b5c-4f7a-800a-6e1b8a35dfa8'),(867,'Clients newly initiated 2j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2j\n \n \n 2020-07-20 15:07:10 UTC\n \n 2021-01-27 15:03:46 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 867\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4689 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 15:07:10',4,'2021-01-27 15:03:46',4,0,NULL,NULL,NULL,'83f23b67-1231-4044-9152-c654f66ebe2e'),(868,'Clients seen given 1 month supply 2j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2j\n \n \n 2020-07-20 15:15:19 UTC\n \n 2021-07-13 14:18:45 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 868\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4689)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 15:15:19',4,'2021-07-13 14:18:45',4,0,NULL,NULL,NULL,'6a992088-7110-42bc-a8df-c65ed16cbdf4'),(869,'Clients given 3 months supply 2j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2j\n \n \n 2020-07-20 15:16:07 UTC\n \n 2021-07-14 08:17:46 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 869\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4689)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 15:16:07',4,'2021-07-14 08:17:46',4,0,NULL,NULL,NULL,'c55d654b-82b7-4426-bd0b-ac03347dbe35'),(870,'Clients given 6 months supply 2j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2j\n \n \n 2020-07-20 15:17:31 UTC\n \n 2021-01-26 19:17:47 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 870\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4689) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4689) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4689) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4689) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4689) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4689) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4689 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 15:17:31',4,'2021-01-26 19:17:47',4,0,NULL,NULL,NULL,'cf31032a-c3ae-4b18-99ae-7765a98e8937'),(871,'Clients given Other months MMD supply 2j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2j\n \n \n 2020-07-20 15:18:22 UTC\n \n 2021-07-24 21:34:55 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 871\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4689)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 15:18:22',4,'2021-07-24 21:34:55',4,0,NULL,NULL,NULL,'b7e4159b-8045-477b-b4d9-24083d1f4fa3'),(872,'Clients newly initiated 2k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2k\n \n \n 2020-07-20 15:29:14 UTC\n \n 2021-01-27 15:04:37 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 872\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4690 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 15:29:14',4,'2021-01-27 15:04:37',4,0,NULL,NULL,NULL,'8b592d42-c141-4d58-b770-d9c9fb2e7195'),(873,'Clients seen given 1 month supply 2k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2k\n \n \n 2020-07-20 15:30:52 UTC\n \n 2021-07-13 14:19:27 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 873\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4690)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 15:30:52',4,'2021-07-13 14:19:27',4,0,NULL,NULL,NULL,'8e0dd16c-a83c-48ba-80ba-0415119dbee4'),(874,'Clients given 3 months supply 2k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2k\n \n \n 2020-07-20 15:32:16 UTC\n \n 2021-07-14 08:18:19 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 874\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4690)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 15:32:16',4,'2021-07-14 08:18:19',4,0,NULL,NULL,NULL,'905f7e40-b853-43b9-a33a-5e2ff8d7874b'),(875,'Clients given 6 months supply 2k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2k\n \n \n 2020-07-20 15:34:06 UTC\n \n 2021-01-26 19:20:27 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 875\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4690) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4690) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4690) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4690) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4690) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4690) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4690 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 15:34:06',4,'2021-01-26 19:20:27',4,0,NULL,NULL,NULL,'1bd5f808-95a3-4645-b2d8-f4413fba1daa'),(876,'Clients given Other months MMD supply 2k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2k\n \n \n 2020-07-20 15:39:15 UTC\n \n 2021-07-24 22:06:18 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 876\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4690)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 15:39:15',4,'2021-07-24 22:06:18',4,0,NULL,NULL,NULL,'4ba2760b-2cef-460e-871f-1b48021fd52a'),(877,'Clients newly initiated 2l','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2l\n \n \n 2020-07-20 16:16:10 UTC\n \n 2021-01-27 15:05:15 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 877\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4691 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 16:16:10',4,'2021-01-27 15:05:15',4,0,NULL,NULL,NULL,'72c7972e-21fb-43b5-84cf-059dd3c33a1f'),(878,'Clients seen given 1 month supply 2l','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2l\n \n \n 2020-07-20 16:16:59 UTC\n \n 2021-07-13 14:20:06 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 878\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4691)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:16:59',4,'2021-07-13 14:20:06',4,0,NULL,NULL,NULL,'988f14b7-3565-4440-af9f-cb44508a59ce'),(879,'Clients given 3 months supply 2l','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2l\n \n \n 2020-07-20 16:18:06 UTC\n \n 2021-07-14 08:19:07 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 879\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4691)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:18:06',4,'2021-07-14 08:19:07',4,0,NULL,NULL,NULL,'f4580b03-d891-4203-a9c0-fcd1a8a78d14'),(880,'Clients given 6 months supply 2l','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2l\n \n \n 2020-07-20 16:19:25 UTC\n \n 2021-01-26 19:23:35 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 880\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4691) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4691) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4691) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4691) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4691) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4691) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4691 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 16:19:25',4,'2021-01-26 19:23:35',4,0,NULL,NULL,NULL,'e1198db3-509c-4c28-8495-b64378232599'),(881,'Clients given Other months MMD supply 2l','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2l\n \n \n 2020-07-20 16:20:39 UTC\n \n 2021-07-24 22:07:31 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 881\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4691)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:20:39',4,'2021-07-24 22:07:31',4,0,NULL,NULL,NULL,'f8cb3fb3-93ab-45d3-99a2-5f0e516de258'),(882,'Clients newly initiated 2m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2m\n \n \n 2020-07-20 16:25:28 UTC\n \n 2021-01-27 15:05:54 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 882\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4692 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 16:25:28',4,'2021-01-27 15:05:54',4,0,NULL,NULL,NULL,'7e35c205-e70c-43c8-ab26-e79255a149f1'),(883,'Clients seen given 1 month supply 2m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2m\n \n \n 2020-07-20 16:26:22 UTC\n \n 2021-07-13 14:20:38 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 883\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4692)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:26:22',4,'2021-07-13 14:20:38',4,0,NULL,NULL,NULL,'4d14334f-0967-4158-9449-38a640f94cc3'),(884,'Clients given 3 months supply 2m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2m\n \n \n 2020-07-20 16:27:47 UTC\n \n 2021-07-14 08:19:37 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 884\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4692)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:27:47',4,'2021-07-14 08:19:37',4,0,NULL,NULL,NULL,'cd30e227-46d5-4866-9c1f-a72e4ed6fdb9'),(885,'Clients given 6 months supply 2m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2m\n \n \n 2020-07-20 16:28:27 UTC\n \n 2021-01-26 19:24:35 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 885\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4692) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4692) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4692) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4692) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4692) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4692) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4692 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 16:28:27',4,'2021-01-26 19:24:35',4,0,NULL,NULL,NULL,'e193a848-d5e1-454a-8266-777440f7ad8d'),(886,'Clients given Other months MMD supply 2n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2n\n \n \n 2020-07-20 16:29:19 UTC\n \n 2021-07-24 22:08:52 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 886\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4693)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:29:19',4,'2021-07-24 22:08:52',4,0,NULL,NULL,NULL,'0a95aada-1316-4abe-b2aa-0b9dde51459f'),(887,'Clients given Other months MMD supply 2m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2m\n \n \n 2020-07-20 16:29:20 UTC\n \n 2021-07-24 22:08:24 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 887\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4692)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:29:20',4,'2021-07-24 22:08:25',4,0,NULL,NULL,NULL,'d341d266-1d27-4921-b731-8dc2ce13d82c'),(888,'Clients newly initiated 2n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2n\n \n \n 2020-07-20 16:33:51 UTC\n \n 2021-01-27 15:06:32 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 888\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4693 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 16:33:51',4,'2021-01-27 15:06:32',4,0,NULL,NULL,NULL,'a9066bb6-bf2a-4d22-9c9b-b22db43322f7'),(889,'Clients seen given 1 month supply 2n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2n\n \n \n 2020-07-20 16:34:42 UTC\n \n 2021-07-13 14:21:11 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 889\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4693)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:34:42',4,'2021-07-13 14:21:11',4,0,NULL,NULL,NULL,'c6422f72-825e-482d-a12d-73ab924f9528'),(890,'Clients given 3 months supply 2n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2n\n \n \n 2020-07-20 16:35:35 UTC\n \n 2021-07-14 08:20:08 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 890\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4693)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:35:35',4,'2021-07-14 08:20:08',4,0,NULL,NULL,NULL,'e0af83be-ad0e-48b9-9ee5-fff184acc985'),(891,'Clients given 6 months supply 2n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2n\n \n \n 2020-07-20 16:36:24 UTC\n \n 2021-01-26 19:27:24 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 891\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4693) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4693) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4693) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4693) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4693) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4693) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4693 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 16:36:24',4,'2021-01-26 19:27:24',4,0,NULL,NULL,NULL,'9a3d0805-b6f9-4eb2-9d05-5420deb24520'),(892,'Clients newly initiated 2o','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2o\n \n \n 2020-07-20 16:49:16 UTC\n \n 2021-01-27 15:07:14 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 892\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4694 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 16:49:16',4,'2021-01-27 15:07:14',4,0,NULL,NULL,NULL,'eb737a94-1eff-4a8b-82d4-d40159ea5817'),(893,'Clients seen given 1 month supply 2o','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2o\n \n \n 2020-07-20 16:50:04 UTC\n \n 2021-07-13 14:22:12 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 893\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4694)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:50:04',4,'2021-07-13 14:22:12',4,0,NULL,NULL,NULL,'52b8c228-c12b-4c0f-81fa-0027d615bd2a'),(894,'Clients given 3 months supply 2o','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2o\n \n \n 2020-07-20 16:51:01 UTC\n \n 2021-07-14 08:20:39 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 894\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4694)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:51:01',4,'2021-07-14 08:20:39',4,0,NULL,NULL,NULL,'69a5e670-44c6-47d9-acd8-6e12dfaa1d80'),(895,'Clients given 6 months supply 2o','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2o\n \n \n 2020-07-20 16:51:39 UTC\n \n 2021-01-26 19:29:32 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 895\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4694) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4694) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4694) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4694) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4694) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4694) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4694 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 16:51:39',4,'2021-01-26 19:29:32',4,0,NULL,NULL,NULL,'4622beff-06b0-46ff-9ffe-9e1a2e6a514f'),(896,'Clients given Other months MMD supply 2o','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2o\n \n \n 2020-07-20 16:52:33 UTC\n \n 2021-07-24 22:09:27 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 896\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4694)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:52:33',4,'2021-07-24 22:09:27',4,0,NULL,NULL,NULL,'34b88c09-e0c3-44b8-8cd2-a431099edd07'),(897,'Clients newly initiated 2p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2p\n \n \n 2020-07-20 16:56:58 UTC\n \n 2021-01-27 15:07:55 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 897\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4695 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 16:56:58',4,'2021-01-27 15:07:55',4,0,NULL,NULL,NULL,'3e67e8e3-a5eb-4cf7-b55b-ef75e74711c5'),(898,'Clients seen given 1 month supply 2p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2p\n \n \n 2020-07-20 16:57:50 UTC\n \n 2021-07-13 14:22:44 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 898\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4695)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:57:50',4,'2021-07-13 14:22:44',4,0,NULL,NULL,NULL,'48813e11-ba00-4da6-bf2f-3f11b709ce62'),(899,'Clients given 3 months supply 2p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2p\n \n \n 2020-07-20 16:58:45 UTC\n \n 2021-07-14 08:21:20 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 899\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4695)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 16:58:45',4,'2021-07-14 08:21:20',4,0,NULL,NULL,NULL,'1a682087-9f0a-45a2-8f0b-c8600f5c6c60'),(900,'Clients given 6 months supply 2p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2p\n \n \n 2020-07-20 17:00:01 UTC\n \n 2021-01-26 19:30:28 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 900\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4695) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4695) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4695) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4695) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4695) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4695) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4695 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 17:00:01',4,'2021-01-26 19:30:28',4,0,NULL,NULL,NULL,'3884fe84-f6b8-490c-a8fb-39733b570582'),(901,'Clients given Other months MMD supply 2p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2p\n \n \n 2020-07-20 17:00:44 UTC\n \n 2021-07-24 22:10:01 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 901\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4695)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 17:00:44',4,'2021-07-24 22:10:01',4,0,NULL,NULL,NULL,'4948619f-ed82-40ed-9da5-44a3ae4169f6'),(902,'Clients newly initiated 2q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2q\n \n \n 2020-07-20 17:03:30 UTC\n \n 2021-01-27 15:09:30 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 902\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4849 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 17:03:30',4,'2021-01-27 15:09:30',4,0,NULL,NULL,NULL,'1f60ad52-150b-4228-8089-9d440e8d0cde'),(903,'Clients seen given 1 month supply 2q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2q\n \n \n 2020-07-20 17:04:25 UTC\n \n 2021-07-13 14:23:27 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 903\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4849)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 17:04:25',4,'2021-07-13 14:23:27',4,0,NULL,NULL,NULL,'ae79b825-cb86-42e5-8953-011f6d9008cf'),(904,'Clients given 3 months supply 2q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2q\n \n \n 2020-07-20 17:05:14 UTC\n \n 2021-07-14 08:21:53 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 904\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4849)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 17:05:14',4,'2021-07-14 08:21:53',4,0,NULL,NULL,NULL,'1606909a-0ff0-4513-a260-b32ee03f4241'),(905,'Clients given 6 months supply 2q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2q\n \n \n 2020-07-20 17:06:30 UTC\n \n 2021-01-26 19:31:31 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 905\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4849) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4849) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4849) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4849) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4849) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4849) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4849 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-07-20 17:06:30',4,'2021-01-26 19:31:31',4,0,NULL,NULL,NULL,'fd6704c7-9485-4842-b91d-1ae58c3bb265'),(906,'Clients given Other months MMD supply 2q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2q\n \n \n 2020-07-20 17:07:20 UTC\n \n 2021-07-24 22:10:33 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 906\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4849)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-07-20 17:07:20',4,'2021-07-24 22:10:33',4,0,NULL,NULL,NULL,'851209e6-8b48-4ec2-8ee7-5d42839b0ddf'),(907,'Clients newly initiated 3d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 3d\n \n \n 2020-07-20 17:24:03 UTC\n \n 2021-01-27 15:21:39 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 907\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4706 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 17:24:03',4,'2021-01-27 15:21:39',4,0,NULL,NULL,NULL,'eb729dfc-4ee5-4de4-aa27-e81aab012d0a'),(908,'Clients newly initiated 3e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 3e\n \n \n 2020-07-20 17:24:57 UTC\n \n 2021-01-27 15:22:17 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 908\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4707 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 17:24:57',4,'2021-01-27 15:22:17',4,0,NULL,NULL,NULL,'1140c832-9daf-4dda-9256-227493e9fa4f'),(909,'Clients newly initiated 3f','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 3f\n \n \n 2020-07-20 17:26:42 UTC\n \n 2021-01-27 15:22:52 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 909\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4708 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 17:26:42',4,'2021-01-27 15:22:52',4,0,NULL,NULL,NULL,'cc49c25f-038c-40bd-8aaa-68be2a51c88b'),(910,'Clients newly initiated 3g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 3g\n \n \n 2020-07-20 17:27:50 UTC\n \n 2021-01-27 15:23:36 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 910\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4709 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 17:27:50',4,'2021-01-27 15:23:36',4,0,NULL,NULL,NULL,'b14d4af3-b58c-48d9-aa33-e0b35aa06d30'),(911,'Clients newly initiated 3h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 3h\n \n \n 2020-07-20 17:29:15 UTC\n \n 2021-01-27 15:24:37 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 911\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4710 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-07-20 17:29:15',4,'2021-01-27 15:24:37',4,0,NULL,NULL,NULL,'d8b0aecd-81dc-4d1b-badd-7949b611bd87'),(912,'CMP_ART Regimen 1month supply 1c','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1c\n \n \n 2020-07-20 19:34:44 UTC\n \n 2020-07-20 19:36:45 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 912\n Clients-newly-initiated-1c OR Clients-seen-given-1-month-supply-1c\n \n \n Clients-newly-initiated-1c\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 Clients-seen-given-1-month-supply-1c\n \n \n \n \n \n \n','2020-07-20 19:34:44',4,'2020-07-20 19:36:45',4,0,NULL,NULL,NULL,'829aeaa7-cb64-4a49-a81b-a040fbe9c8cd'),(913,'CMP_ART Regimen 1month supply 1d','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1d\n \n \n 2020-07-20 19:38:24 UTC\n \n 2020-07-20 19:40:12 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 913\n Clients-seen-given-1-month-supply-1d OR Clients-newly-initiated-1d-\n \n \n Clients-seen-given-1-month-supply-1d\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 Clients-newly-initiated-1d-\n \n \n \n \n \n \n','2020-07-20 19:38:24',4,'2020-07-20 19:40:12',4,0,NULL,NULL,NULL,'74bef2b6-1548-4408-a0d8-f06267b194cd'),(914,'CMP_ART Regimen 1month supply 1e','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1e\n \n \n 2020-07-20 19:41:21 UTC\n \n 2020-07-20 19:43:07 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 914\n Clients-newly-initiated-1e OR Clients-seen-given-1-month-supply-1e\n \n \n Clients-newly-initiated-1e\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 Clients-seen-given-1-month-supply-1e\n \n \n \n \n \n \n','2020-07-20 19:41:21',4,'2020-07-20 19:43:07',4,0,NULL,NULL,NULL,'010de706-fc5b-46bc-af84-92e43b167718'),(915,'CMP_ART Regimen 1month supply 1g','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1g\n \n \n 2020-07-20 19:43:21 UTC\n \n 2020-07-21 00:56:20 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 915\n Clients-newly-initiated-1g- OR Clients-seen-given-1-month-supply-1g\n \n \n Clients-newly-initiated-1g-\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 Clients-seen-given-1-month-supply-1g\n \n \n \n \n \n \n','2020-07-20 19:43:21',4,'2020-07-21 00:56:20',4,0,NULL,NULL,NULL,'57d7a749-47e3-468d-b861-77762886a260'),(916,'CMP_ART Regimen 1month supply 1h','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1h\n \n \n 2020-07-21 00:56:37 UTC\n \n 2020-07-21 00:58:05 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 916\n Clients-newly-initiated-1h OR Clients-seen-given-1-month-supply-1h\n \n \n Clients-newly-initiated-1h\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 Clients-seen-given-1-month-supply-1h\n \n \n \n \n \n \n','2020-07-21 00:56:37',4,'2020-07-21 00:58:05',4,0,NULL,NULL,NULL,'dac9644e-de7d-4d01-842a-5e0bd3b04be6'),(917,'CMP_ART Regimen 1month supply 1j','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1j\n \n \n 2020-07-21 00:58:23 UTC\n \n 2020-07-21 00:59:43 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 917\n Clients-seen-given-1-month-supply-1j OR Clients-newly-initiated-1j\n \n \n Clients-seen-given-1-month-supply-1j\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 Clients-newly-initiated-1j\n \n \n \n \n \n \n','2020-07-21 00:58:23',4,'2020-07-21 00:59:43',4,0,NULL,NULL,NULL,'6c85c1eb-bafe-4fcf-b839-ec9bac116397'),(918,'CMP_ART Regimen 1month supply 1k','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1k\n \n \n 2020-07-21 01:00:03 UTC\n \n 2020-07-21 01:01:26 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 918\n Clients-seen-given-1-month-supply-1k OR Clients-newly-initiated-1k\n \n \n Clients-seen-given-1-month-supply-1k\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 Clients-newly-initiated-1k\n \n \n \n \n \n \n','2020-07-21 01:00:03',4,'2020-07-21 01:01:26',4,0,NULL,NULL,NULL,'df97af0c-0e5c-4c03-ac17-6fd6989c9f52'),(919,'CMP_ART Regimen 1month supply 1m','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1m\n \n \n 2020-07-21 01:01:47 UTC\n \n 2020-07-21 01:03:02 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 919\n Clients-seen-given-1-month-supply-1m OR Clients-newly-initiated-1m\n \n \n Clients-seen-given-1-month-supply-1m\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 Clients-newly-initiated-1m\n \n \n \n \n \n \n','2020-07-21 01:01:47',4,'2020-07-21 01:03:02',4,0,NULL,NULL,NULL,'c6314f22-4686-415a-9180-aec975e149b6'),(920,'CMP_ART Regimen 1month supply 1n','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1n\n \n \n 2020-07-21 01:03:35 UTC\n \n 2020-07-21 01:04:49 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 920\n Clients-seen-given-1-month-supply-1n OR Clients-newly-initiated-1n\n \n \n Clients-seen-given-1-month-supply-1n\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 Clients-newly-initiated-1n\n \n \n \n \n \n \n','2020-07-21 01:03:35',4,'2020-07-21 01:04:49',4,0,NULL,NULL,NULL,'d63a7ee0-2c04-4c43-a559-420c2c5833d3'),(921,'CMP_ART Regimen 1month supply 1p','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1p\n \n \n 2020-07-21 01:05:09 UTC\n \n 2020-07-21 01:06:57 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 921\n Clients-seen-given-1-month-supply-1p OR Clients-newly-initiated-1p\n \n \n Clients-seen-given-1-month-supply-1p\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 Clients-newly-initiated-1p\n \n \n \n \n \n \n','2020-07-21 01:05:09',4,'2020-07-21 01:06:57',4,0,NULL,NULL,NULL,'dd9f9e82-0406-47c8-a725-bd696fbc3c12'),(922,'CMP_ART Regimen 1month supply 1q','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 1q\n \n \n 2020-07-21 01:07:11 UTC\n \n 2020-07-21 01:08:27 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 922\n Clients-newly-initiated-1q OR Clients-seen-given-1-month-supply-1q\n \n \n Clients-newly-initiated-1q\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 Clients-seen-given-1-month-supply-1q\n \n \n \n \n \n \n','2020-07-21 01:07:11',4,'2020-07-21 01:08:27',4,0,NULL,NULL,NULL,'5db23287-5dac-4b0f-a298-f4b6b5280c83'),(923,'CI04a: Adult 1st Line 1month supply 1c','Adults on 1st line 1c given 1month supply during the reporting period','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI04a: Adult 1st Line 1month supply 1c\n Adults on 1st line 1c given 1month supply during the reporting period\n \n 2020-07-21 01:12:25 UTC\n \n 2021-07-13 10:51:25 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 923\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:12:25',4,'2021-07-13 10:51:25',4,0,NULL,NULL,NULL,'afc603fa-52eb-4575-b911-da59f667ab73'),(924,'CI04b: Adult 1st Line 3 months supply 1c','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI04b: Adult 1st Line 3 months supply 1c\n \n \n 2020-07-21 01:15:26 UTC\n \n 2020-07-21 01:16:56 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 924\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:15:26',4,'2020-07-21 01:16:56',4,0,NULL,NULL,NULL,'7ac59930-19d9-4d19-bd11-c5053a450a26'),(925,'CI04c: Adult 1st Line 6 months supply 1c','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI04c: Adult 1st Line 6 months supply 1c\n \n \n 2020-07-21 01:17:44 UTC\n \n 2020-07-21 01:18:44 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 925\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:17:44',4,'2020-07-21 01:18:44',4,0,NULL,NULL,NULL,'62bc19a6-55a7-42af-b32d-bc3922ccada1'),(926,'CI04d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1c','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI04d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1c\n \n \n 2020-07-21 01:20:02 UTC\n \n 2020-07-21 01:21:42 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 926\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:20:02',4,'2020-07-21 01:21:42',4,0,NULL,NULL,NULL,'e47fb0fe-b9e3-441b-8750-3aeb6835425e'),(927,'CI05a: Adult 1st Line 1month supply 1d','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI05a: Adult 1st Line 1month supply 1d\n \n \n 2020-07-21 01:23:38 UTC\n \n 2021-07-13 10:52:30 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 927\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:23:38',4,'2021-07-13 10:52:30',4,0,NULL,NULL,NULL,'5a9ccea7-0a17-4507-93a1-1c065039d658'),(928,'CI05b: Adult 1st Line 3 months supply 1d','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI05b: Adult 1st Line 3 months supply 1d\n \n \n 2020-07-21 01:25:51 UTC\n \n 2020-07-21 01:26:43 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 928\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:25:51',4,'2020-07-21 01:26:43',4,0,NULL,NULL,NULL,'f1b32cd7-2259-4d99-9f4e-807e1ee36198'),(929,'CI05c: Adult 1st Line 6 months supply 1d','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI05c: Adult 1st Line 6 months supply 1d\n \n \n 2020-07-21 01:27:34 UTC\n \n 2020-07-21 01:28:31 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 929\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:27:34',4,'2020-07-21 01:28:31',4,0,NULL,NULL,NULL,'397b18ba-7676-47d7-8b74-36fb553fce5a'),(930,'CI05d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1d','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI05d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1d\n \n \n 2020-07-21 01:29:44 UTC\n \n 2020-07-21 01:30:44 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 930\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:29:44',4,'2020-07-21 01:30:44',4,0,NULL,NULL,NULL,'f5ef0c56-b3d7-48f0-8edf-f86a9ce3a131'),(931,'CI06a: Adult 1st Line 1month supply 1e','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI06a: Adult 1st Line 1month supply 1e\n \n \n 2020-07-21 01:32:17 UTC\n \n 2021-07-13 10:53:24 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 931\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:32:17',4,'2021-07-13 10:53:24',4,0,NULL,NULL,NULL,'951db50d-c81e-4873-937c-ef24fd97341b'),(932,'CI06b: Adult 1st Line 3 months supply 1e','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI06b: Adult 1st Line 3 months supply 1e\n \n \n 2020-07-21 01:34:03 UTC\n \n 2020-07-21 01:35:29 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 932\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:34:03',4,'2020-07-21 01:35:29',4,0,NULL,NULL,NULL,'9e37c53c-e2f6-407b-98d8-74609842b178'),(933,'CI06c: Adult 1st Line 6 months supply 1e','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI06c: Adult 1st Line 6 months supply 1e\n \n \n 2020-07-21 01:36:59 UTC\n \n 2020-07-21 01:37:49 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 933\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:36:59',4,'2020-07-21 01:37:49',4,0,NULL,NULL,NULL,'1934b675-10f8-4a35-a937-146270fc115f'),(934,'CI06d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1e','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI06d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1e\n \n \n 2020-07-21 01:38:46 UTC\n \n 2020-07-21 01:39:52 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 934\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:38:46',4,'2020-07-21 01:39:52',4,0,NULL,NULL,NULL,'71cd4a88-5f58-4d9c-8580-fee04ddc08d9'),(935,'CI08a: Adult 1st Line 1month supply 1g','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI08a: Adult 1st Line 1month supply 1g\n \n \n 2020-07-21 01:51:34 UTC\n \n 2021-07-13 10:54:56 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 935\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:51:34',4,'2021-07-13 10:54:56',4,0,NULL,NULL,NULL,'a13ddfbe-eca2-491c-acc9-504634fa6d82'),(936,'CI08b: Adult 1st Line 3 months supply 1g','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI08b: Adult 1st Line 3 months supply 1g\n \n \n 2020-07-21 01:53:02 UTC\n \n 2020-07-21 01:53:51 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 936\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:53:02',4,'2020-07-21 01:53:51',4,0,NULL,NULL,NULL,'70995f20-ec52-4069-a33e-0c8dd9e98ab9'),(937,'CI08c: Adult 1st Line 6 months supply 1g','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI08c: Adult 1st Line 6 months supply 1g\n \n \n 2020-07-21 01:54:19 UTC\n \n 2020-07-21 01:55:25 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 937\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:54:19',4,'2020-07-21 01:55:25',4,0,NULL,NULL,NULL,'183b513c-124d-4e45-9a79-3051d09e2cc4'); +INSERT INTO `serialized_object` VALUES (938,'CI08d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1g','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI08d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1g\n \n \n 2020-07-21 01:57:00 UTC\n \n 2020-07-21 01:58:00 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 938\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 01:57:00',4,'2020-07-21 01:58:00',4,0,NULL,NULL,NULL,'dcdbd00a-5102-4e52-af19-04ff1d36d0c7'),(939,'CI09a: Adult 1st Line 1month supply 1h','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI09a: Adult 1st Line 1month supply 1h\n \n \n 2020-07-21 02:25:29 UTC\n \n 2021-07-13 10:55:41 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 939\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:25:29',4,'2021-07-13 10:55:41',4,0,NULL,NULL,NULL,'616f1562-8733-4c9e-b6e2-87a17106acaf'),(940,'CI09b: Adult 1st Line 3 months supply 1h','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI09b: Adult 1st Line 3 months supply 1h\n \n \n 2020-07-21 02:26:56 UTC\n \n 2020-07-21 02:27:40 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 940\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:26:56',4,'2020-07-21 02:27:40',4,0,NULL,NULL,NULL,'06dbe648-2a96-4fe4-aff3-575e84f4315b'),(941,'CI09c: Adult 1st Line 6 months supply 1h','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI09c: Adult 1st Line 6 months supply 1h\n \n \n 2020-07-21 02:28:15 UTC\n \n 2020-07-21 02:28:58 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 941\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:28:15',4,'2020-07-21 02:28:58',4,0,NULL,NULL,NULL,'c581e381-1a36-4591-9dc2-a8f978b9ae49'),(942,'CI09d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1h','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI09d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1h\n \n \n 2020-07-21 02:29:36 UTC\n \n 2020-07-21 02:30:16 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 942\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:29:36',4,'2020-07-21 02:30:16',4,0,NULL,NULL,NULL,'4fb604a8-0527-4eaf-bbdd-1a099d145648'),(943,'CI10a: Adult 1st Line 1month supply 1j','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI10a: Adult 1st Line 1month supply 1j\n \n \n 2020-07-21 02:34:17 UTC\n \n 2021-07-08 11:09:31 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 943\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:34:17',4,'2021-07-08 11:09:31',4,0,NULL,NULL,NULL,'1f473c7d-8597-41b4-992b-7baa77ed4aca'),(944,'CI10b: Adult 1st Line 3 months supply 1j','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI10b: Adult 1st Line 3 months supply 1j\n \n \n 2020-07-21 02:45:28 UTC\n \n 2020-07-21 02:46:14 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 944\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:45:28',4,'2020-07-21 02:46:14',4,0,NULL,NULL,NULL,'13a0c750-2408-4cd2-b1df-d453f45e3a00'),(945,'CI10c: Adult 1st Line 6 months supply 1j','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI10c: Adult 1st Line 6 months supply 1j\n \n \n 2020-07-21 02:46:48 UTC\n \n 2020-07-21 02:47:40 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 945\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:46:48',4,'2020-07-21 02:47:40',4,0,NULL,NULL,NULL,'26dd119e-e715-4f92-91f5-ba0f369673d9'),(946,'CI10d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1j','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI10d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1j\n \n \n 2020-07-21 02:48:29 UTC\n \n 2020-07-21 02:49:06 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 946\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:48:29',4,'2020-07-21 02:49:06',4,0,NULL,NULL,NULL,'ca557633-3e4c-49ca-9462-ca58f8010d92'),(947,'CI11a: Adult 1st Line 1month supply 1k','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI11a: Adult 1st Line 1month supply 1k\n \n \n 2020-07-21 02:51:55 UTC\n \n 2021-07-13 10:49:34 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 947\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:51:55',4,'2021-07-13 10:49:34',4,0,NULL,NULL,NULL,'dc095e0e-2c62-4c56-972b-17a67263614b'),(948,'CI11b: Adult 1st Line 3 months supply 1k','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI11b: Adult 1st Line 3 months supply 1k\n \n \n 2020-07-21 02:53:36 UTC\n \n 2020-07-21 02:54:27 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 948\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:53:36',4,'2020-07-21 02:54:27',4,0,NULL,NULL,NULL,'e32caf13-d848-4e21-97fa-e89d9563f306'),(949,'CI11c: Adult 1st Line 6 months supply 1k','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI11c: Adult 1st Line 6 months supply 1k\n \n \n 2020-07-21 02:54:50 UTC\n \n 2020-07-21 02:55:35 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 949\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:54:50',4,'2020-07-21 02:55:35',4,0,NULL,NULL,NULL,'0e12fae3-e9e2-40b2-a849-12376cb478a2'),(950,'CI11d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1k','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI11d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1k\n \n \n 2020-07-21 02:56:26 UTC\n \n 2020-07-21 02:57:11 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 950\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 02:56:26',4,'2020-07-21 02:57:11',4,0,NULL,NULL,NULL,'24257a6a-1879-4dd8-bd3d-f058279e0207'),(951,'CI12a: Adult 1st Line 1month supply 1m','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI12a: Adult 1st Line 1month supply 1m\n \n \n 2020-07-21 03:00:02 UTC\n \n 2021-07-13 10:58:00 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 951\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:00:02',4,'2021-07-13 10:58:00',4,0,NULL,NULL,NULL,'0ef6adce-502f-47eb-8795-429caf1b23ae'),(952,'CI12b: Adult 1st Line 3 months supply 1m','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI12b: Adult 1st Line 3 months supply 1m\n \n \n 2020-07-21 03:01:23 UTC\n \n 2020-07-21 03:02:10 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 952\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:01:23',4,'2020-07-21 03:02:10',4,0,NULL,NULL,NULL,'bf47b708-0b0b-43d8-a05b-273cff29afea'),(953,'CI12c: Adult 1st Line 6 months supply 1m','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI12c: Adult 1st Line 6 months supply 1m\n \n \n 2020-07-21 03:02:37 UTC\n \n 2020-07-21 03:03:20 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 953\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:02:37',4,'2020-07-21 03:03:20',4,0,NULL,NULL,NULL,'d969925a-4cbd-42c0-bf1a-cb78639c24ae'),(954,'CI12d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1m','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI12d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1m\n \n \n 2020-07-21 03:03:46 UTC\n \n 2020-07-21 03:10:58 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 954\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:03:46',4,'2020-07-21 03:10:58',4,0,NULL,NULL,NULL,'7df200bd-d206-4346-8d1f-a4afe7c120e2'),(955,'CI13a: Adult 1st Line 1month supply 1n','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI13a: Adult 1st Line 1month supply 1n\n \n \n 2020-07-21 03:05:47 UTC\n \n 2021-07-13 11:00:35 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 955\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:05:47',4,'2021-07-13 11:00:35',4,0,NULL,NULL,NULL,'32ff69f7-5a24-4515-a13a-59a4c2a0ef5c'),(956,'CI13b: Adult 1st Line 3 months supply 1n','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI13b: Adult 1st Line 3 months supply 1n\n \n \n 2020-07-21 03:07:19 UTC\n \n 2020-07-21 03:08:06 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 956\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:07:19',4,'2020-07-21 03:08:06',4,0,NULL,NULL,NULL,'1309392d-c442-4929-926d-bb5fc0e707eb'),(957,'CI13c: Adult 1st Line 6 months supply 1n','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI13c: Adult 1st Line 6 months supply 1n\n \n \n 2020-07-21 03:08:41 UTC\n \n 2020-07-21 03:09:19 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 957\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:08:41',4,'2020-07-21 03:09:19',4,0,NULL,NULL,NULL,'5af5abae-803c-43d8-9afa-04f11ee98fb0'),(958,'CI13d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1n','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI13d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1n\n \n \n 2020-07-21 03:11:12 UTC\n \n 2020-07-21 03:11:52 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 958\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:11:12',4,'2020-07-21 03:11:52',4,0,NULL,NULL,NULL,'21233a7a-d6c5-493f-a2a0-9a03f786176b'),(959,'CI14a: Adult 1st Line 1month supply 1p','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI14a: Adult 1st Line 1month supply 1p\n \n \n 2020-07-21 03:13:17 UTC\n \n 2021-07-13 11:01:47 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 959\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:13:17',4,'2021-07-13 11:01:47',4,0,NULL,NULL,NULL,'16876004-32fb-4a96-a177-2d0a96e7a208'),(960,'CI14b: Adult 1st Line 3 months supply 1p','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI14b: Adult 1st Line 3 months supply 1p\n \n \n 2020-07-21 03:15:36 UTC\n \n 2020-07-21 03:16:23 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 960\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:15:36',4,'2020-07-21 03:16:23',4,0,NULL,NULL,NULL,'e7b8e8a4-f8ee-4a2e-81cd-d97f5e7ceb8b'),(961,'CI14c: Adult 1st Line 6 months supply 1p','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI14c: Adult 1st Line 6 months supply 1p\n \n \n 2020-07-21 03:16:49 UTC\n \n 2020-07-21 03:17:52 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 961\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:16:49',4,'2020-07-21 03:17:52',4,0,NULL,NULL,NULL,'4969a61b-0fdc-4c63-b686-ba7822cfb08d'),(962,'CI14d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1p','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI14d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1p\n \n \n 2020-07-21 03:18:27 UTC\n \n 2020-07-21 03:19:04 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 962\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:18:27',4,'2020-07-21 03:19:04',4,0,NULL,NULL,NULL,'c3e318e4-0469-415f-832e-44d5b5e714f2'),(963,'CI15a: Adult 1st Line 1month supply 1q','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI15a: Adult 1st Line 1month supply 1q\n \n \n 2020-07-21 03:19:49 UTC\n \n 2021-07-13 11:03:04 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 963\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:19:49',4,'2021-07-13 11:03:04',4,0,NULL,NULL,NULL,'fb000c62-ea24-41e4-8645-8b0c6da882af'),(964,'CI15b: Adult 1st Line 3 months supply 1q','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI15b: Adult 1st Line 3 months supply 1q\n \n \n 2020-07-21 03:20:53 UTC\n \n 2020-07-21 03:21:47 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 964\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:20:53',4,'2020-07-21 03:21:47',4,0,NULL,NULL,NULL,'7463cbbb-24b0-41ba-ab49-a9113892ede3'),(965,'CI15c: Adult 1st Line 6 months supply 1q','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI15c: Adult 1st Line 6 months supply 1q\n \n \n 2020-07-21 03:22:10 UTC\n \n 2020-07-21 03:23:13 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 965\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:22:10',4,'2020-07-21 03:23:13',4,0,NULL,NULL,NULL,'ab56677f-53c2-428f-9f0b-d275436fbeac'),(966,'CI15d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1q','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI15d: Adult 1st Line Other (2, 4, 5 or 7+) MMD supply 1q\n \n \n 2020-07-21 03:23:46 UTC\n \n 2020-07-21 03:24:21 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 966\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-07-21 03:23:46',4,'2020-07-21 03:24:21',4,0,NULL,NULL,NULL,'ee8d0792-83e6-4a75-9d29-880203b1d97f'),(967,'tests','1mnth 2c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n tests\n 1mnth 2c\n \n 2020-07-24 14:51:44 UTC\n \n 2020-07-24 14:52: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 967\n','2020-07-24 14:51:44',4,'2020-07-24 14:52:23',4,0,NULL,NULL,NULL,'36cc1013-4264-4c43-af7a-5c097f01d1bc'),(968,'CMP_ART Regimen 1month supply 2c','1mnth 2c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2c\n 1mnth 2c\n \n 2020-07-24 14:53:18 UTC\n \n 2020-07-24 15:00: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 968\n Clients-newly-initiated-2c OR Clients-seen-given-1-month-supply-2c\n \n \n Clients-newly-initiated-2c\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 Clients-seen-given-1-month-supply-2c\n \n \n \n \n \n \n','2020-07-24 14:53:18',4,'2020-07-24 15:00:26',4,0,NULL,NULL,NULL,'90455a27-26e1-4043-8199-8f7bda6f55da'),(969,'CMP_ART Regimen 1month supply 2d','1mnth 2d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2d\n 1mnth 2d\n \n 2020-07-24 15:01:04 UTC\n \n 2020-07-24 15:04: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 969\n Clients-newly-initiated-2d OR Clients-seen-given-1-month-supply-2d\n \n \n Clients-newly-initiated-2d\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 Clients-seen-given-1-month-supply-2d\n \n \n \n \n \n \n','2020-07-24 15:01:04',4,'2020-07-24 15:04:46',4,0,NULL,NULL,NULL,'4dbab0a2-b33e-4ed9-ae7d-1c4fd08fa665'),(970,'CMP_ART Regimen 1month supply 2e','1mnth 2e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2e\n 1mnth 2e\n \n 2020-07-24 15:05:29 UTC\n \n 2020-07-24 15:07: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 970\n Clients-newly-initiated-2e OR Clients-seen-given-1-month-supply-2e\n \n \n Clients-newly-initiated-2e\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 Clients-seen-given-1-month-supply-2e\n \n \n \n \n \n \n','2020-07-24 15:05:29',4,'2020-07-24 15:07:56',4,0,NULL,NULL,NULL,'c561c725-73b6-4ccf-a159-849c5fceee4d'),(971,'CMP_ART Regimen 1month supply 2f','1 mnth 2f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2f\n 1 mnth 2f\n \n 2020-07-24 15:08:32 UTC\n \n 2020-07-24 15: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 971\n Clients-newly-initiated-2f- OR Clients-seen-given-1-month-supply-2f\n \n \n Clients-newly-initiated-2f-\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 Clients-seen-given-1-month-supply-2f\n \n \n \n \n \n \n','2020-07-24 15:08:32',4,'2020-07-24 15:11:10',4,0,NULL,NULL,NULL,'7c9575bf-11fe-43d5-b643-6ad64139702c'),(972,'CMP_ART Regimen 1month supply 2g','1mnth 2g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2g\n 1mnth 2g\n \n 2020-07-24 15:12:42 UTC\n \n 2020-07-24 15:16: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 972\n Clients-newly-initiated-2g OR Clients-seen-given-1-month-supply-2g\n \n \n Clients-newly-initiated-2g\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 Clients-seen-given-1-month-supply-2g\n \n \n \n \n \n \n','2020-07-24 15:12:42',4,'2020-07-24 15:16:14',4,0,NULL,NULL,NULL,'f44d2ca7-dd58-414e-b2bb-0c25dfbcc2bf'),(973,'CMP_ART Regimen 1month supply 2h','1month 2h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2h\n 1month 2h\n \n 2020-07-24 15:17:06 UTC\n \n 2020-07-24 15: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 973\n Clients-newly-initiated-2g OR Clients-seen-given-1-month-supply-2h\n \n \n Clients-newly-initiated-2g\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 Clients-seen-given-1-month-supply-2h\n \n \n \n \n \n \n','2020-07-24 15:17:06',4,'2020-07-24 15:19:35',4,0,NULL,NULL,NULL,'c3fb524c-828b-4aa9-ad18-73c3afcd4b01'),(974,'CMP_ART Regimen 1month supply 2j','1month 2j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2j\n 1month 2j\n \n 2020-07-24 15:20:13 UTC\n \n 2020-07-24 15: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 974\n Clients-newly-initiated-2j OR Clients-seen-given-1-month-supply-2j\n \n \n Clients-newly-initiated-2j\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 Clients-seen-given-1-month-supply-2j\n \n \n \n \n \n \n','2020-07-24 15:20:13',4,'2020-07-24 15:25:05',4,0,NULL,NULL,NULL,'b1ab8586-4a72-4a16-b5d7-9482e6eae2fc'),(975,'CMP_ART Regimen 1month supply 2k','1mnth 2k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2k\n 1mnth 2k\n \n 2020-07-24 15:25:27 UTC\n \n 2020-07-24 15:30: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 975\n Clients-seen-given-1-month-supply-2k OR Clients-newly-initiated-2k\n \n \n Clients-seen-given-1-month-supply-2k\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 Clients-newly-initiated-2k\n \n \n \n \n \n \n','2020-07-24 15:25:27',4,'2020-07-24 15:30:29',4,0,NULL,NULL,NULL,'50c6447e-caa4-4ea4-8363-2959de4a7365'),(976,'CMP_ART Regimen 1month supply 2l','1mnth 2l','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2l\n 1mnth 2l\n \n 2020-07-24 15:30:56 UTC\n \n 2020-07-24 15:32: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 976\n Clients-seen-given-1-month-supply-2l OR Clients-newly-initiated-2l\n \n \n Clients-seen-given-1-month-supply-2l\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 Clients-newly-initiated-2l\n \n \n \n \n \n \n','2020-07-24 15:30:56',4,'2020-07-24 15:32:29',4,0,NULL,NULL,NULL,'872e6d0b-64c6-4ff1-a839-44dfc2bc7a9e'),(977,'CMP_ART Regimen 1month supply 2m','1mnth 2m','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2m\n 1mnth 2m\n \n 2020-07-26 06:13:53 UTC\n \n 2020-07-26 06:19: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 977\n Clients-seen-given-1-month-supply-2m OR Clients-newly-initiated-2m\n \n \n Clients-seen-given-1-month-supply-2m\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 Clients-newly-initiated-2m\n \n \n \n \n \n \n','2020-07-26 06:13:53',4,'2020-07-26 06:19:50',4,0,NULL,NULL,NULL,'d7dd8d8a-e3a1-472c-90fc-e0c450303c18'),(978,'CMP_ART Regimen 1month supply 2n','1mnth 2n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2n\n 1mnth 2n\n \n 2020-07-26 06:20:22 UTC\n \n 2020-07-26 06: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 978\n Clients-seen-given-1-month-supply-2n OR Clients-newly-initiated-2n\n \n \n Clients-seen-given-1-month-supply-2n\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 Clients-newly-initiated-2n\n \n \n \n \n \n \n','2020-07-26 06:20:22',4,'2020-07-26 06:24:10',4,0,NULL,NULL,NULL,'7f61ff5a-9a20-4b98-aea5-db7e27f4e2d2'),(979,'CMP_ART Regimen 1month supply 2o','1mnth 2o','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2o\n 1mnth 2o\n \n 2020-07-26 07:10:30 UTC\n \n 2020-07-26 07:14: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 979\n Clients-seen-given-1-month-supply-2o OR Clients-newly-initiated-2o\n \n \n Clients-seen-given-1-month-supply-2o\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 Clients-newly-initiated-2o\n \n \n \n \n \n \n','2020-07-26 07:10:30',4,'2020-07-26 07:14:11',4,0,NULL,NULL,NULL,'ba08340b-e00e-4de7-b5d7-8bee853471c0'),(980,'CMP_ART Regimen 1month supply 2p','1mnth 2p','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2p\n 1mnth 2p\n \n 2020-07-26 07:17:55 UTC\n \n 2020-07-26 07:36: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 980\n Clients-seen-given-1-month-supply-2p OR Clients-newly-initiated-2p\n \n \n Clients-seen-given-1-month-supply-2p\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 Clients-newly-initiated-2p\n \n \n \n \n \n \n','2020-07-26 07:17:55',4,'2020-07-26 07:36:10',4,0,NULL,NULL,NULL,'06709fce-50ff-4008-aec7-900443e2c2bc'),(981,'CMP_ART Regimen 1month supply 2q','1mnth 2q','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2q\n 1mnth 2q\n \n 2020-07-26 07:39:23 UTC\n \n 2020-07-26 07: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 981\n Clients-seen-given-1-month-supply-2q OR Clients-newly-initiated-2q\n \n \n Clients-seen-given-1-month-supply-2q\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 Clients-newly-initiated-2q\n \n \n \n \n \n \n','2020-07-26 07:39:23',4,'2020-07-26 07:42:14',4,0,NULL,NULL,NULL,'6d8b0fd8-70d9-4f09-8770-93a8a063bbbd'),(982,'2020_adult_arv_2ndline_regimen','new dataset adult 2nd line regimen','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_adult_arv_2ndline_regimen\n new dataset adult 2nd line regimen\n \n 2020-07-26 09:16:18 UTC\n \n 2020-07-26 09:16: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 982\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','2020-07-26 09:16:18',4,'2020-07-26 09:16:34',4,0,NULL,NULL,NULL,'8e5b796f-0a4c-4c90-af06-b3ef89810ef2'),(983,'2020_adult_arv_2ndline_regimen Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_adult_arv_2ndline_regimen Data Set\n \n 2020-07-26 09:16:34 UTC\n \n 2020-12-03 07:35: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 983\n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 2c1mnth\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_Age\n 15+yrs\n \n \n \n \n \n 2c3mnths\n \n \n \n \n \n \n \n \n \n 2d1mnth\n \n \n \n \n \n \n \n \n \n 2d3mnths\n \n \n \n \n \n \n \n \n \n 2e1mnth\n \n \n \n \n \n \n \n \n \n 2e3mnths\n \n \n \n \n \n \n \n \n \n 2f1mnth\n \n \n \n \n \n \n \n \n \n 2f3mnths\n \n \n \n \n \n \n \n \n \n 2g1mnth\n \n \n \n \n \n \n \n \n \n 2g3mnths\n \n \n \n \n \n \n \n \n \n 2h1mnth\n \n \n \n \n \n \n \n \n \n 2h3mnths\n \n \n \n \n \n \n \n \n \n 2i1mnth\n \n \n \n \n \n \n \n \n \n 2i3mnths\n \n \n \n \n \n \n \n \n \n 2j1mnth\n \n \n \n \n \n \n \n \n \n 2j3mnths\n \n \n \n \n \n \n \n \n \n 2k1mnth\n \n \n \n \n \n \n \n \n \n 2k3mnths\n \n \n \n \n \n \n \n \n \n 2l1mnth\n \n \n \n \n \n \n \n \n \n 2l3mnths\n \n \n \n \n \n \n \n \n \n 2m1mnth\n \n \n \n \n \n \n \n \n \n 2m3mnths\n \n \n \n \n \n \n \n \n \n 2n1mnth\n \n \n \n \n \n \n \n \n \n 2n3mnths\n \n \n \n \n \n \n \n \n \n 2o1mnth\n \n \n \n \n \n \n \n \n \n 2o3mnths\n \n \n \n \n \n \n \n \n \n 2p1mnth\n \n \n \n \n \n \n \n \n \n 2p3mnths\n \n \n \n \n \n \n \n \n \n 2q1mnth\n \n \n \n \n \n \n \n \n \n 2q3mnths\n \n \n \n \n \n \n \n \n \n 2r1mnth\n \n \n \n \n \n \n \n \n \n 2r3mnths\n \n \n \n \n \n \n \n \n \n 2s1mnth\n \n \n \n \n \n \n \n \n \n 2s3mnths\n \n \n \n \n \n \n \n \n \n','2020-07-26 09:16:34',4,'2020-12-03 07:35:24',4,0,NULL,NULL,NULL,'ef7a6344-1f91-4926-ba02-d45bbff8e6a6'),(985,'CMP_ART Regimen 1month supply 3b','1mnth 3b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 3b\n 1mnth 3b\n \n 2020-07-26 14:45:35 UTC\n \n 2020-07-30 10:21: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 985\n Clients-seen-given-1-month-supply-3b OR Clients-newly-initiated-3b\n \n \n Clients-seen-given-1-month-supply-3b\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 Clients-newly-initiated-3b\n \n \n \n \n \n \n','2020-07-26 14:45:35',4,'2020-07-30 10:21:37',4,0,NULL,NULL,NULL,'4ac8f9b1-b672-4687-a463-74a6806e4045'),(986,'CMP_ART Regimen 1month supply 3c','1mnth 3c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 3c\n 1mnth 3c\n \n 2020-07-26 14:52:06 UTC\n \n 2020-07-30 10:25: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 986\n Clients-newly-initiated-3c OR Clients-seen-given-1-month-supply-3c\n \n \n Clients-newly-initiated-3c\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 Clients-seen-given-1-month-supply-3c\n \n \n \n \n \n \n','2020-07-26 14:52:06',4,'2020-07-30 10:25:28',4,0,NULL,NULL,NULL,'759d2eb9-1dd6-4d76-865f-7cb1d6ef75cf'),(987,'CMP_ART Regimen 1month supply 3d','1mnth 3d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 3d\n 1mnth 3d\n \n 2020-07-26 14:56:17 UTC\n \n 2020-07-30 10:27: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 987\n Clients-newly-initiated-3d OR Clients-seen-given-1-month-supply-3d\n \n \n Clients-newly-initiated-3d\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 Clients-seen-given-1-month-supply-3d\n \n \n \n \n \n \n','2020-07-26 14:56:17',4,'2020-07-30 10:27:56',4,0,NULL,NULL,NULL,'3bfa5700-82fc-4e92-a9f1-84a2a2e5d098'),(988,'CMP_ART Regimen 1month supply 3e','1mnth 3e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 3e\n 1mnth 3e\n \n 2020-07-26 14:59:13 UTC\n \n 2020-07-30 10:30: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 988\n Clients-newly-initiated-3e OR Clients-seen-given-1-month-supply-3e\n \n \n Clients-newly-initiated-3e\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 Clients-seen-given-1-month-supply-3e\n \n \n \n \n \n \n','2020-07-26 14:59:13',4,'2020-07-30 10:30:08',4,0,NULL,NULL,NULL,'1a8828f4-337f-4563-9018-82d8df61b92c'),(989,'CMP_ART Regimen 1month supply 3f','1mnth 3f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 3f\n 1mnth 3f\n \n 2020-07-26 15:02:32 UTC\n \n 2020-07-30 10:32: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 989\n Clients-newly-initiated-3f OR Clients-seen-given-1-month-supply-3f\n \n \n Clients-newly-initiated-3f\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 Clients-seen-given-1-month-supply-3f\n \n \n \n \n \n \n','2020-07-26 15:02:32',4,'2020-07-30 10:32:56',4,0,NULL,NULL,NULL,'ccceead2-c7f3-4c50-b922-0e4566dc6c5f'),(990,'CMP_ART Regimen 1month supply 3g','1mnth 3g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 3g\n 1mnth 3g\n \n 2020-07-26 15:08:27 UTC\n \n 2020-07-30 10:34: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 990\n Clients-newly-initiated-3g OR Clients-seen-given-1-month-supply-3g\n \n \n Clients-newly-initiated-3g\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 Clients-seen-given-1-month-supply-3g\n \n \n \n \n \n \n','2020-07-26 15:08:27',4,'2020-07-30 10:34:43',4,0,NULL,NULL,NULL,'f036add2-8f10-4f62-a371-4afac2b81e97'),(991,'CMP_ART Regimen 1month supply 3h','1mnth 3h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 3h\n 1mnth 3h\n \n 2020-07-26 15:10:27 UTC\n \n 2020-07-30 10:36: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 991\n Clients-newly-initiated-3h OR Clients-seen-given-1-month-supply-3h\n \n \n Clients-newly-initiated-3h\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 Clients-seen-given-1-month-supply-3h\n \n \n \n \n \n \n','2020-07-26 15:10:27',4,'2020-07-30 10:36:16',4,0,NULL,NULL,NULL,'761cf953-a41c-45d1-bf0a-265a97685aee'),(992,'2020_adult_arv_3rdline_regimen','new dataset 3rdline ARV','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_adult_arv_3rdline_regimen\n new dataset 3rdline ARV\n \n 2020-07-26 15:13:37 UTC\n \n 2020-07-26 19:27: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 992\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','2020-07-26 15:13:37',4,'2020-07-26 19:27:44',4,0,NULL,NULL,NULL,'afe451d4-5080-4689-b64a-75f0211f81a3'),(993,'2020_adult_arv_2ndline_regimen Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_adult_arv_2ndline_regimen Data Set\n \n 2020-07-26 15:13:44 UTC\n \n 2020-07-26 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 993\n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 3a1mnth\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_Age\n 15+yrs\n \n \n \n \n \n 3b1mnth\n \n \n \n \n \n \n \n \n \n 3c1mnth\n \n \n \n \n \n \n \n \n \n 3d1mnth\n \n \n \n \n \n \n \n \n \n 3e1mnth\n \n \n \n \n \n \n \n \n \n 3f1mnth\n \n \n \n \n \n \n \n \n \n 3g1mnth\n \n \n \n \n \n \n \n \n \n 3h1mnth\n \n \n \n \n \n \n \n \n \n','2020-07-26 15:13:44',4,'2020-07-26 20:13:06',4,0,NULL,NULL,NULL,'01bbedc4-b494-4465-b5c8-cbaa75c5f0d5'),(994,'CMP_ART Regimen 1month supply 3a','1month 3a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 3a\n 1month 3a\n \n 2020-07-29 22:32:01 UTC\n \n 2020-07-30 09:52: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 994\n Clients-seen-given-1-month-supply-3a OR Clients-newly-initiated-3a\n \n \n Clients-seen-given-1-month-supply-3a\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 Clients-newly-initiated-3a\n \n \n \n \n \n \n','2020-07-29 22:32:01',4,'2020-07-30 09:52:26',4,0,NULL,NULL,NULL,'a7795190-fca8-4cc7-903c-ef70798e3763'),(995,'CI33a:Enrolled in Pre ART this month','pre ART enrolled','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI33a:Enrolled in Pre ART this month\n pre ART enrolled\n \n 2020-08-04 15:01:44 UTC\n \n 2020-08-04 15:06: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 995\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-08-04 15:01:44',4,'2020-08-04 15:06:11',4,0,NULL,NULL,NULL,'ff2143b3-5c22-4373-b026-e2ad9230d145'),(997,'CI33b: Clients ever enrolled on PrE ART','ever pre art','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI33b: Clients ever enrolled on PrE ART\n ever pre art\n \n 2020-08-04 16:10:56 UTC\n \n 2020-08-04 16:16: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 997\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-08-04 16:10:56',4,'2020-08-04 16:16:32',4,0,NULL,NULL,NULL,'63a41dcf-c43f-4143-a703-406e75e917bb'),(998,'CI34a: ART and Pre ART seen this month','care clients seen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI34a: ART and Pre ART seen this month\n care clients seen\n \n 2020-08-04 16:31:46 UTC\n \n 2020-08-04 16:58: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 998\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-08-04 16:31:46',4,'2020-08-04 16:58:48',4,0,NULL,NULL,NULL,'2dc3ab54-fb26-445c-a9f5-788588571414'),(999,'CI30a: ART and Pre ART screened for TB','ART and Pre ART screened for TB','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI30a: ART and Pre ART screened for TB\n ART and Pre ART screened for TB\n \n 2020-08-04 17:01:37 UTC\n \n 2020-08-04 17: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 999\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-08-04 17:01:37',4,'2020-08-04 17:02:59',4,0,NULL,NULL,NULL,'ff11b48e-496f-4399-a9ef-f10a6f8a1fe1'),(1002,'DM_Children_Age','Children Age Groups','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n DM_Children_Age\n Children Age Groups\n \n 2020-09-09 10:58:53 UTC\n \n 2020-09-09 11:06:02 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n 1002\n \n \n 01-04yrs\n \n \n \n \n maxAge\n 4\n \n \n minAge\n 1\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 05-09yrs\n \n \n \n \n maxAge\n 9\n \n \n minAge\n 5\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 10-14yrs\n \n \n \n \n maxAge\n 14\n \n \n minAge\n 10\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n Under 1yr\n \n \n \n \n maxAge\n 0\n \n \n minAge\n 0\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n','2020-09-09 12:58:53',4,'2020-09-09 13:06:02',4,0,NULL,NULL,NULL,'229c55ed-b8a7-4f88-b3b6-a0df413f524c'),(1004,'DM_Adults_Age','Adult Age Groups','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n DM_Adults_Age\n Adult Age Groups\n \n 2020-09-10 16:49:59 UTC\n \n 2020-09-10 16:56:40 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n 1004\n \n \n 121-200yrs\n \n \n \n \n maxAge\n 200\n \n \n minAge\n 121\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 15-19yrs\n \n \n \n \n maxAge\n 19\n \n \n minAge\n 15\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 20-24yrs\n \n \n \n \n maxAge\n 24\n \n \n minAge\n 20\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 25-29yrs\n \n \n \n \n maxAge\n 29\n \n \n minAge\n 25\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 30-34yrs\n \n \n \n \n maxAge\n 34\n \n \n minAge\n 30\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 35-39yrs\n \n \n \n \n maxAge\n 39\n \n \n minAge\n 35\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 40-44yrs\n \n \n \n \n maxAge\n 44\n \n \n minAge\n 40\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 45-49yrs\n \n \n \n \n maxAge\n 49\n \n \n minAge\n 45\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 50-120yrs\n \n \n \n \n maxAge\n 120\n \n \n minAge\n 50\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n','2020-09-10 18:49:59',4,'2020-09-10 18:56:40',4,0,NULL,NULL,NULL,'5c344e8a-2fd0-4dff-a4b4-48516c0298e3'),(1005,'DM_Finer_Age','Finer Age Groups','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n DM_Finer_Age\n Finer Age Groups\n \n 2020-09-10 16:59:10 UTC\n \n 2020-09-16 13:09:14 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n 1005\n \n \n 01-04yrs\n \n \n \n \n maxAge\n 4\n \n \n minAge\n 1\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 05-09yrs\n \n \n \n \n maxAge\n 9\n \n \n minAge\n 5\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 10-14yrs\n \n \n \n \n maxAge\n 14\n \n \n minAge\n 10\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 121-200yrs\n \n \n \n \n maxAge\n 200\n \n \n minAge\n 121\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 15-19yrs\n \n \n \n \n maxAge\n 19\n \n \n minAge\n 15\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 20-24yrs\n \n \n \n \n maxAge\n 24\n \n \n minAge\n 20\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 25-29yrs\n \n \n \n \n maxAge\n 29\n \n \n minAge\n 25\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 30-34yrs\n \n \n \n \n maxAge\n 34\n \n \n minAge\n 30\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 35-39yrs\n \n \n \n \n maxAge\n 39\n \n \n minAge\n 35\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 40-44yrs\n \n \n \n \n maxAge\n 44\n \n \n minAge\n 40\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 45-49yrs\n \n \n \n \n maxAge\n 49\n \n \n minAge\n 45\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 50Plus\n \n \n \n \n maxAge\n 120\n \n \n minAge\n 50\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n Under1yr\n \n \n \n \n maxAge\n 0\n \n \n minAge\n 0\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n','2020-09-10 18:59:10',4,'2020-09-16 15:09:14',4,0,NULL,NULL,NULL,'47af7610-5e91-4b2d-962d-0d317ffe03fb'),(1006,'2020_ART_Current',' ART CARE - NEW AND CURRENT NUMBER OF PERSONS STARTED ON ART','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_ART_Current\n ART CARE - NEW AND CURRENT NUMBER OF PERSONS STARTED ON ART\n \n 2020-09-16 12:53:38 UTC\n \n 2020-09-30 11: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 1006\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','2020-09-16 14:53:38',4,'2020-09-30 13:59:49',4,0,NULL,NULL,NULL,'f5608fc7-5bc6-49cc-a9b0-d52917f63cd2'),(1007,'2020_ART_Current Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2020_ART_Current Data Set\n \n 2020-09-16 12:53:44 UTC\n \n 2020-09-16 17:06: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 1007\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n DefaultF1-\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n DefaultF10\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n DefaultF15\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n DefaultF20\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n DefaultF25\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n DefaultF30\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n DefaultF35\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n DefaultF40\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n DefaultF45\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n DefaultF5-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n DefaultF50\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n DefaultF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n DefaultM1-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n DefaultM10\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n DefaultM15\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n DefaultM20\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n DefaultM25\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n DefaultM30\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n DefaultM35\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n DefaultM40\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n DefaultM45\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n DefaultM5-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n DefaultM50\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n DefaultM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n DiedClient\n \n \n \n \n \n \n \n \n \n LostToFU\n \n \n \n \n \n \n \n \n \n MMD_F1-4\n \n \n \n \n \n \n \n \n \n MMD_F10-14\n \n \n \n \n \n \n MMD_F15-19\n \n \n \n \n \n \n MMD_F20-24\n \n \n \n \n \n \n MMD_F25-29\n \n \n \n \n \n \n MMD_F30-34\n \n \n \n \n \n \n MMD_F35-39\n \n \n \n \n \n \n MMD_F40-44\n \n \n \n \n \n \n MMD_F45-49\n \n \n \n \n \n \n MMD_F5-9\n \n \n \n \n \n \n MMD_F50\n \n \n \n \n \n \n MMD_F<1\n \n \n \n \n \n \n MMD_M1-4\n \n \n \n \n \n \n MMD_M10-14\n \n \n \n \n \n \n MMD_M15-19\n \n \n \n \n \n \n MMD_M20-24\n \n \n \n \n \n \n MMD_M25-29\n \n \n \n \n \n \n MMD_M30-34\n \n \n \n \n \n \n MMD_M35-39\n \n \n \n \n \n \n MMD_M40-44\n \n \n \n \n \n \n MMD_M45-49\n \n \n \n \n \n \n MMD_M5-9\n \n \n \n \n \n \n MMD_M50\n \n \n \n \n \n \n MMD_M<1\n \n \n \n \n \n \n MissedF1-4\n \n \n \n \n \n \n \n \n \n MissedF10-\n \n \n \n \n \n \n MissedF15-\n \n \n \n \n \n \n MissedF20-\n \n \n \n \n \n \n MissedF25-\n \n \n \n \n \n \n MissedF30-\n \n \n \n \n \n \n MissedF35-\n \n \n \n \n \n \n MissedF40-\n \n \n \n \n \n \n MissedF45-\n \n \n \n \n \n \n MissedF5-9\n \n \n \n \n \n \n MissedF50\n \n \n \n \n \n \n MissedF<1\n \n \n \n \n \n \n MissedM1-4\n \n \n \n \n \n \n MissedM10-\n \n \n \n \n \n \n MissedM15-\n \n \n \n \n \n \n MissedM20-\n \n \n \n \n \n \n MissedM25-\n \n \n \n \n \n \n MissedM30-\n \n \n \n \n \n \n MissedM35-\n \n \n \n \n \n \n MissedM40-\n \n \n \n \n \n \n MissedM45-\n \n \n \n \n \n \n MissedM5-9\n \n \n \n \n \n \n MissedM50\n \n \n \n \n \n \n MissedM<1\n \n \n \n \n \n \n NewF1-4\n \n \n \n \n \n \n \n \n \n NewF10-14\n \n \n \n \n \n \n NewF15-19\n \n \n \n \n \n \n NewF20-24\n \n \n \n \n \n \n NewF25-29\n \n \n \n \n \n \n NewF30-34\n \n \n \n \n \n \n NewF35-39\n \n \n \n \n \n \n NewF40-44\n \n \n \n \n \n \n NewF45-49\n \n \n \n \n \n \n NewF5-9\n \n \n \n \n \n \n NewF50\n \n \n \n \n \n \n NewF<1\n \n \n \n \n \n \n NewM1-4\n \n \n \n \n \n \n NewM10-14\n \n \n \n \n \n \n NewM15-19\n \n \n \n \n \n \n NewM20-24\n \n \n \n \n \n \n NewM25-29\n \n \n \n \n \n \n NewM30-34\n \n \n \n \n \n \n NewM35-39\n \n \n \n \n \n \n NewM40-44\n \n \n \n \n \n \n NewM45-49\n \n \n \n \n \n \n NewM5-9\n \n \n \n \n \n \n NewM50\n \n \n \n \n \n \n NewM<1\n \n \n \n \n \n \n Restarted\n \n \n \n \n \n \n \n \n \n SeenF1-4\n \n \n \n \n \n \n \n \n \n SeenF10-14\n \n \n \n \n \n \n SeenF15-19\n \n \n \n \n \n \n SeenF20-24\n \n \n \n \n \n \n SeenF25-29\n \n \n \n \n \n \n SeenF30-34\n \n \n \n \n \n \n SeenF35-39\n \n \n \n \n \n \n SeenF40-44\n \n \n \n \n \n \n SeenF45-49\n \n \n \n \n \n \n SeenF5-9\n \n \n \n \n \n \n SeenF50\n \n \n \n \n \n \n SeenF<1\n \n \n \n \n \n \n SeenM1-4\n \n \n \n \n \n \n SeenM10-14\n \n \n \n \n \n \n SeenM15-19\n \n \n \n \n \n \n SeenM20-24\n \n \n \n \n \n \n SeenM25-29\n \n \n \n \n \n \n SeenM30-34\n \n \n \n \n \n \n SeenM35-39\n \n \n \n \n \n \n SeenM40-44\n \n \n \n \n \n \n SeenM45-49\n \n \n \n \n \n \n SeenM5-9\n \n \n \n \n \n \n SeenM50\n \n \n \n \n \n \n SeenM<1\n \n \n \n \n \n \n StoppedART\n \n \n \n \n \n \n \n \n \n TransferIn\n \n \n \n \n \n \n \n \n \n TransferOu\n \n \n \n \n \n \n \n \n \n','2020-09-16 14:53:44',4,'2020-09-16 19:06:19',4,0,NULL,NULL,NULL,'c84add35-e6ec-4ef4-81d3-53f3d0b7b38b'),(1008,'weight_query_updated','weights','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.NumericObsCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n weight_query_updated\n weights\n \n 2020-11-16 10:06:11 UTC\n \n 2020-11-17 12:17:11 UTC\n \n \n onOrAfter\n \n java.util.Date\n true\n \n \n onOrBefore\n \n java.util.Date\n true\n \n \n locationList\n \n org.openmrs.Location\n java.util.List\n true\n \n \n value1\n \n java.lang.Double\n true\n \n \n value2\n \n java.lang.Double\n true\n \n \n 1008\n LAST\n \n \n \n \n \n GREATER_EQUAL\n LESS_THAN\n','2020-11-16 10:06:11',4,'2020-11-17 12:17:11',4,0,NULL,NULL,NULL,'59e2cda8-7991-4837-b0d0-a83f0fcbd8db'),(1009,'revised_child_weight','revised weight','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n revised_child_weight\n revised weight\n \n 2020-11-16 10:08:00 UTC\n \n 2020-11-20 10:06: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 1009\n \n \n 0-3.9kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 4.0\n \n \n value1\n 0.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n 10-13.9kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 14.0\n \n \n value1\n 10.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n 100+kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 120.0\n \n \n value1\n 100.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n 14-19.9kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 20.0\n \n \n value1\n 14.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n 20-24.9kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 25.0\n \n \n value1\n 20.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n 25-34.9kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 35.0\n \n \n value1\n 25.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n 35+kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 100.0\n \n \n value1\n 35.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n 35pluskg\n \n \n \n \n onOrBefore\n ${}\n \n \n value2\n 70.0\n \n \n value1\n 35.0\n \n \n onOrAfter\n ${}\n \n \n \n \n \n 4-5.9kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 6.0\n \n \n value1\n 4.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n 6-9.9kg\n \n \n \n \n onOrBefore\n ${endDate}\n \n \n value2\n 10.0\n \n \n value1\n 6.0\n \n \n onOrAfter\n ${startDate}\n \n \n \n \n \n','2020-11-16 12:08:00',4,'2020-11-20 12:06:34',4,0,NULL,NULL,NULL,'e74d2f97-2a34-41e4-9ebd-e8ed8430bd7b'),(1010,'Children ARV Regimen_1stLine','Children ARV Regimen_1stLine','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\n Children ARV Regimen_1stLine\n \n 2020-11-16 11:27:59 UTC\n \n 2020-12-03 12: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 1010\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','2020-11-16 11:27:59',4,'2020-12-03 12:40:42',4,0,NULL,NULL,NULL,'369c2c45-a71a-48e6-bfe8-9edb1b962fe8'),(1011,'4h regimen testing Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4h regimen testing Data Set\n \n 2020-11-16 11:28:17 UTC\n \n 2021-02-04 08:45: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 1011\n \n \n revised_child_weight\n \n \n \n \n endDate\n ${endDate}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n Children_ages\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 4L0to3.9\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 revised_child_weight\n 0-3.9kg\n \n \n Children_ages\n Children 0to14\n \n \n \n \n \n 4L10to13.9\n \n \n \n \n revised_child_weight\n 10-13.9kg\n \n \n Children_ages\n Children 0to14\n \n \n \n \n \n 4L14to19.9\n \n \n \n \n revised_child_weight\n 14-19.9kg\n \n \n Children_ages\n Children 0to14\n \n \n \n \n \n 4L20to24.9\n \n \n \n \n revised_child_weight\n 20-24.9kg\n \n \n Children_ages\n Children 0to14\n \n \n \n \n \n 4L25to34.9\n \n \n \n \n revised_child_weight\n 25-34.9kg\n \n \n Children_ages\n Children 0to14\n \n \n \n \n \n 4L35plus\n \n \n \n \n revised_child_weight\n 35pluskg\n \n \n Children_ages\n Children 0to14\n \n \n \n \n \n 4L4to5.9\n \n \n \n \n revised_child_weight\n 4-5.9kg\n \n \n Children_ages\n Children 0to14\n \n \n \n \n \n 4L6to9.9\n \n \n \n \n revised_child_weight\n 6-9.9kg\n \n \n Children_ages\n Children 0to14\n \n \n \n \n \n 4c0to3.9\n \n \n \n \n \n \n \n \n \n 4c10to13.9\n \n \n \n \n \n \n 4c14to19.9\n \n \n \n \n \n \n 4c20to24.9\n \n \n \n \n \n \n 4c25to34.9\n \n \n \n \n \n \n 4c35plus\n \n \n \n \n \n \n 4c4to5.9\n \n \n \n \n \n \n 4c6to9.9\n \n \n \n \n \n \n 4d03to3.9\n \n \n \n \n \n \n \n \n \n 4d10to13.9\n \n \n \n \n \n \n 4d14to19.9\n \n \n \n \n \n \n 4d20to24.9\n \n \n \n \n \n \n 4d25to34.9\n \n \n \n \n \n \n 4d35plus\n \n \n \n \n \n \n 4d4to5.9\n \n \n \n \n \n \n 4d6to9.9\n \n \n \n \n \n \n 4e03to3.9\n \n \n \n \n \n \n \n \n \n 4e10to13.9\n \n \n \n \n \n \n 4e14to19.9\n \n \n \n \n \n \n 4e20to24.9\n \n \n \n \n \n \n 4e25to34.9\n \n \n \n \n \n \n 4e35plus\n \n \n \n \n \n \n 4e4to5.9\n \n \n \n \n \n \n 4e6to9.9\n \n \n \n \n \n \n 4f0to3.9\n \n \n \n \n \n \n \n \n \n 4f10to13.9\n \n \n \n \n \n \n 4f14to19.9\n \n \n \n \n \n \n 4f20to24.9\n \n \n \n \n \n \n 4f25to34.9\n \n \n \n \n \n \n 4f35plus\n \n \n \n \n \n \n 4f4to5.9\n \n \n \n \n \n \n 4f6to9.9\n \n \n \n \n \n \n 4g0to3.9\n \n \n \n \n \n \n \n \n \n 4g10to13.9\n \n \n \n \n \n \n 4g14to19.9\n \n \n \n \n \n \n 4g20to24.9\n \n \n \n \n \n \n 4g25to34.9\n \n \n \n \n \n \n 4g35plus\n \n \n \n \n \n \n 4g4to5.9\n \n \n \n \n \n \n 4g6to9.9\n \n \n \n \n \n \n 4h0to3.9\n \n \n \n \n \n \n \n \n \n 4h10to13.9\n \n \n \n \n \n \n 4h14to19.9\n \n \n \n \n \n \n 4h20to24.9\n \n \n \n \n \n \n 4h25to34.9\n \n \n \n \n \n \n 4h35plus\n \n \n \n \n \n \n 4h4to5.9\n \n \n \n \n \n \n 4h6to9.9\n \n \n \n \n \n \n 4j0to3.9\n \n \n \n \n \n \n \n \n \n 4j10to13.9\n \n \n \n \n \n \n 4j14to19.9\n \n \n \n \n \n \n 4j20to24.9\n \n \n \n \n \n \n 4j25to34.9\n \n \n \n \n \n \n 4j35plus\n \n \n \n \n \n \n 4j4to5.9\n \n \n \n \n \n \n 4j6to9.9\n \n \n \n \n \n \n 4k0to3.9\n \n \n \n \n \n \n \n \n \n 4k10to13.9\n \n \n \n \n \n \n 4k14to19.9\n \n \n \n \n \n \n 4k20to24.9\n \n \n \n \n \n \n 4k25to34.9\n \n \n \n \n \n \n 4k35plus\n \n \n \n \n \n \n 4k4to5.9\n \n \n \n \n \n \n 4k6to9.9\n \n \n \n \n \n \n','2020-11-16 11:28:17',4,'2021-02-04 08:45:06',4,0,NULL,NULL,NULL,'017e9c81-7e67-4b81-b9ac-9953c2d93f4b'),(1013,'4h regimen testing Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 4h regimen testing Data Set\n \n 2020-11-16 11:29:47 UTC\n \n 2020-11-23 16: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 1013\n \n \n revised_child_weight\n \n \n \n \n endDate\n ${endDate}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n \n \n 4L0to3.9\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 revised_child_weight\n 0-3.9kg\n \n \n \n \n \n 4L10to13.9\n \n \n \n \n revised_child_weight\n 10-13.9kg\n \n \n \n \n \n 4L14to19.9\n \n \n \n \n revised_child_weight\n 14-19.9kg\n \n \n \n \n \n 4L20to24.9\n \n \n \n \n revised_child_weight\n 20-24.9kg\n \n \n \n \n \n 4L25to34.9\n \n \n \n \n revised_child_weight\n 25-34.9kg\n \n \n \n \n \n 4L35+kg\n \n \n \n \n revised_child_weight\n 35+kg\n \n \n \n \n \n 4L4to5.9\n \n \n \n \n revised_child_weight\n 4-5.9kg\n \n \n \n \n \n 4L6to9.9\n \n \n \n \n revised_child_weight\n 6-9.9kg\n \n \n \n \n \n 4c0to3.9\n \n \n \n \n \n \n \n \n \n 4c10to13.9\n \n \n \n \n \n \n 4c14to19.9\n \n \n \n \n \n \n 4c20to24.9\n \n \n \n \n \n \n 4c25to34.9\n \n \n \n \n \n \n 4c35+kg\n \n \n \n \n \n \n 4c4to5.9\n \n \n \n \n \n \n 4c6to9.9\n \n \n \n \n \n \n 4d0to3.9\n \n \n \n \n \n \n \n \n \n 4d10to13.9\n \n \n \n \n \n \n 4d14to19.9\n \n \n \n \n \n \n 4d20to24.9\n \n \n \n \n \n \n 4d25to34.9\n \n \n \n \n \n \n 4d35+kg\n \n \n \n \n \n \n 4d4to5.9\n \n \n \n \n \n \n 4d6to9.9\n \n \n \n \n \n \n 4e03to3.9\n \n \n \n \n \n \n \n \n \n 4e10to13.9\n \n \n \n \n \n \n 4e14to19.9\n \n \n \n \n \n \n 4e20to24.9\n \n \n \n \n \n \n 4e25to34.9\n \n \n \n \n \n \n 4e35+kg\n \n \n \n \n \n \n 4e4to5.9\n \n \n \n \n \n \n 4e6to9.9\n \n \n \n \n \n \n 4f0to3.9\n \n \n \n \n \n \n \n \n \n 4f10to13.9\n \n \n \n \n \n \n 4f14to19.9\n \n \n \n \n \n \n 4f20to24.9\n \n \n \n \n \n \n 4f25to34.9\n \n \n \n \n \n \n 4f35+kg\n \n \n \n \n \n \n 4f4to5.9\n \n \n \n \n \n \n 4f6to9.9\n \n \n \n \n \n \n 4g0to3.9\n \n \n \n \n \n \n \n \n \n 4g10to13.9\n \n \n \n \n \n \n 4g14to19.9\n \n \n \n \n \n \n 4g20to24.9\n \n \n \n \n \n \n 4g25to34.9\n \n \n \n \n \n \n 4g35+kg\n \n \n \n \n \n \n 4g4to5.9\n \n \n \n \n \n \n 4g6to9.9\n \n \n \n \n \n \n 4h0to3.9\n \n \n \n \n \n \n \n \n \n 4h10to13.9\n \n \n \n \n \n \n 4h14to19.9\n \n \n \n \n \n \n 4h20to24.9\n \n \n \n \n \n \n 4h25to34.9\n \n \n \n \n \n \n 4h35+kg\n \n \n \n \n \n \n 4h4to5.9\n \n \n \n \n \n \n 4h6to9.9\n \n \n \n \n \n \n 4j0to3.9\n \n \n \n \n \n \n \n \n \n 4j10to13.9\n \n \n \n \n \n \n 4j14to19.9\n \n \n \n \n \n \n 4j20to24.9\n \n \n \n \n \n \n 4j25to34.9\n \n \n \n \n \n \n 4j35+kg\n \n \n \n \n \n \n 4j4to5.9\n \n \n \n \n \n \n \n \n \n 4j6to9.9\n \n \n \n \n \n \n 4k0to3.9\n \n \n \n \n \n \n 4k10to13.9\n \n \n \n \n \n \n 4k14to19.9\n \n \n \n \n \n \n 4k20to24.9\n \n \n \n \n \n \n 4k25to34.9\n \n \n \n \n \n \n 4k35+kg\n \n \n \n \n \n \n 4k4to5.9\n \n \n \n \n \n \n 4k6to9.9\n \n \n \n \n \n \n','2020-11-16 13:29:47',4,'2020-11-23 18:20:12',4,0,NULL,NULL,NULL,'9f1d2576-51cf-452c-ab0f-b68c0cb2289f'),(1014,'adult_arv_2r_1mnth',' 1month supply of 2r','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2r_1mnth\n 1month supply of 2r\n \n 2020-11-20 11:48:38 UTC\n \n 2020-11-20 11:49:10 UTC\n \n \n location\n \n java.lang.String\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 1014\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4850 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-11-20 13:48:38',4,'2020-11-20 13:49:10',4,0,NULL,NULL,NULL,'fb71139e-a156-4964-a304-f80360ba200b'),(1015,'adult_arv_2r_3mnth','3mnths supply of 2r','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2r_3mnth\n 3mnths supply of 2r\n \n 2020-11-20 11:50:29 UTC\n \n 2020-12-02 19:51: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 1015\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4850 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-11-20 11:50:29',4,'2020-12-02 19:51:13',4,0,NULL,NULL,NULL,'8f18aeea-7884-4a10-9d05-85ae3c160bd0'),(1016,'Clients given 3 months supply 2r','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2r\n None\n \n 2020-11-20 11:52:23 UTC\n \n 2021-07-14 08: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 1016\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4850)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-11-20 11:52:23',4,'2021-07-14 08:22:25',4,0,NULL,NULL,NULL,'80905b89-7a28-4cda-a44b-25b0a291211d'),(1017,'Clients given 6 months supply 2r','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2r\n None\n \n 2020-11-20 11:55:09 UTC\n \n 2021-01-26 19:36: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 1017\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4850) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4850) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4850) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4850) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4850) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4850) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4850 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-11-20 11:55:09',4,'2021-01-26 19:36:05',4,0,NULL,NULL,NULL,'f81d3821-0b33-4721-8548-09089e951a1e'),(1018,'Clients given Other months MMD supply 2r','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2r\n None\n \n 2020-11-20 11:57:01 UTC\n \n 2021-07-24 23:08: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 1018\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4850)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-11-20 11:57:01',4,'2021-07-24 23:08:16',4,0,NULL,NULL,NULL,'ae3c1ee8-0e33-49bb-8c7f-2492ddd244da'),(1019,'Clients newly initiated 2r','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2r\n None\n \n 2020-11-20 12:01:14 UTC\n \n 2021-01-27 15:10: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 1019\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4850 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-11-20 12:01:14',4,'2021-01-27 15:10:26',4,0,NULL,NULL,NULL,'14abb047-bc53-4d1f-bee5-7c4112dad68d'),(1020,'Clients seen given 1 month supply 2r','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2r\n None\n \n 2020-11-20 12:03:07 UTC\n \n 2021-07-13 14:24: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 1020\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4850)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-11-20 12:03:07',4,'2021-07-13 14:24:13',4,0,NULL,NULL,NULL,'e4c0b8ee-d729-49d9-b05d-3af1aed9fe08'),(1021,'CMP_ART Regimen 1month supply 2r',' 1mnth 2r','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2r\n 1mnth 2r\n \n 2020-11-20 12:06:02 UTC\n \n 2020-12-03 10: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 1021\n Clients-seen-given-1-month-supply-2r OR Clients-newly-initiated-2r\n \n \n Clients-seen-given-1-month-supply-2r\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 Clients-newly-initiated-2r\n \n \n \n \n \n \n','2020-11-20 12:06:02',4,'2020-12-03 10:49:43',4,0,NULL,NULL,NULL,'5dc2d400-2d6f-4d68-bbdd-58f969efdee9'),(1022,'adult_arv_2s_1mnth',' 1month supply of 2s','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2s_1mnth\n 1month supply of 2s\n \n 2020-11-23 16:01:14 UTC\n \n 2020-11-23 16:01:33 UTC\n \n \n location\n \n java.lang.String\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 1022\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4851 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4175)\n','2020-11-23 18:01:14',4,'2020-11-23 18:01:33',4,0,NULL,NULL,NULL,'41b5c235-8f68-4765-9cb7-3052079b1e52'),(1023,'adult_arv_2s_3mnth',' 3mnths supply of 2s','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2s_3mnth\n 3mnths supply of 2s\n \n 2020-11-23 16:07:24 UTC\n \n 2020-12-02 19: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 1023\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nINNER JOIN person ON person.person_id = o.person_id \nwhere (o.location_id =:location or parent_location =:location) \nAND o.voided = 0 \nand o.person_id in (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 2250 and value_coded = 4851 \n ) \nand o.person_id in \n (select o.person_id \n from obs o \n where obs_datetime BETWEEN :startDate AND :endDate \n and concept_id = 4174 and value_coded = 4177 \n)\n','2020-11-23 16:07:24',4,'2020-12-02 19:56:27',4,0,NULL,NULL,NULL,'e75199de-2b55-458d-ae92-fe19aae857bb'),(1024,'Clients given 3 months supply 2s','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2s\n None\n \n 2020-11-23 16:08:20 UTC\n \n 2021-07-14 08:22: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 1024\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 4851)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-11-23 16:08:20',4,'2021-07-14 08:22:56',4,0,NULL,NULL,NULL,'b83fd0d2-7016-453c-8f4d-a5ab08ec00b0'),(1025,'Clients given 6 months supply 2s','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2s\n None\n \n 2020-11-23 16:09:50 UTC\n \n 2021-01-26 19:35: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 1025\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4851) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 4851) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4851) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4851) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4851) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4851) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 4851 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-11-23 16:09:50',4,'2021-01-26 19:35:14',4,0,NULL,NULL,NULL,'5de7880b-4de6-4770-923d-dc53c71bdd11'),(1026,'Clients given Other months MMD supply 2s','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2s\n None\n \n 2020-11-23 16:12:53 UTC\n \n 2021-07-24 23:11: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 1026\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4851)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-11-23 16:12:53',4,'2021-07-24 23:11:30',4,0,NULL,NULL,NULL,'9026be35-1eaf-4a05-aba3-c2dfffa9061e'),(1027,'Clients newly initiated 2s','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2s\n None\n \n 2020-11-23 16:14:46 UTC\n \n 2021-01-27 15:11: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 1027\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 4851 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-11-23 16:14:46',4,'2021-01-27 15:11:07',4,0,NULL,NULL,NULL,'36ca3e4d-651f-4209-b140-480752765843'),(1028,'Clients seen given 1 month supply 2s','None','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2s\n None\n \n 2020-11-23 16:16:24 UTC\n \n 2021-07-13 14:24: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 1028\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4851)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-11-23 16:16:24',4,'2021-07-13 14:24:49',4,0,NULL,NULL,NULL,'48fdb859-4147-457e-8af6-3e2bf0ca1a0c'),(1029,'CMP_ART Regimen 1month supply 2s','1mnth 2s','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2s\n 1mnth 2s\n \n 2020-11-23 16:18:09 UTC\n \n 2020-11-23 16: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 1029\n Clients-seen-given-1-month-supply-2s OR Clients-newly-initiated-2s\n \n \n Clients-newly-initiated-2s\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 Clients-seen-given-1-month-supply-2s\n \n \n \n \n \n \n','2020-11-23 18:18:09',4,'2020-11-23 18:34:51',4,0,NULL,NULL,NULL,'a6720665-3d0b-4b70-b463-fb8c9e567d64'),(1030,'Clients given 3 months supply other ','other regimen supplied','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply other \n other regimen supplied\n \n 2020-11-30 21:17:21 UTC\n \n 2021-06-30 10:45: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 1030\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2143)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-11-30 21:17:21',4,'2021-06-30 10:45:45',4,0,NULL,NULL,NULL,'c28adf82-c0fb-446c-b3c2-101d4d4f146e'),(1031,'Clients given 3 months supply 2i','3mnths of 2i regimen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 2i\n 3mnths of 2i regimen\n \n 2020-11-30 21:18:46 UTC\n \n 2021-07-14 08:17: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 1031\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 = 3678)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 84 AND datediff(latest_follow_up, max_observation)< 112)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-11-30 21:18:46',4,'2021-07-14 08:17:08',4,0,NULL,NULL,NULL,'092b1af7-5dca-4b33-8a3f-98700da3548b'),(1036,'Clients given 3 months supply 3e','3mnths of 3e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 3e\n 3mnths of 3e\n \n 2020-11-30 21:27:28 UTC\n \n 2021-01-26 17: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 1036\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4707) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4707) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4707) \n \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4707 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-11-30 21:27:28',4,'2021-01-26 17:40:25',4,0,NULL,NULL,NULL,'b757ed79-c1de-4d4e-9d6d-c78202a81a4d'),(1037,'Clients given 3 months supply 3f','3mnths of 3f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 3f\n 3mnths of 3f\n \n 2020-11-30 21:28:58 UTC\n \n 2021-01-26 17:42: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 1037\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4708) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4708) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4708) \n \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4708 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-11-30 21:28:58',4,'2021-01-26 17:42:35',4,0,NULL,NULL,NULL,'34ca96df-ff64-4c2a-9ee3-6b25a5473382'),(1038,'Clients given 3 months supply 3g','3months of 3g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 3g\n 3months of 3g\n \n 2020-11-30 21:30:47 UTC\n \n 2021-01-26 17:44: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 1038\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4709) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4709) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4709) \n \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4709 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2020-11-30 21:30:47',4,'2021-01-26 17:44:05',4,0,NULL,NULL,NULL,'55dead5b-5fa0-434e-90df-16ff7a6923fb'),(1040,'Children ARV Regimen_2ndLine','2ndLine 0 to 14yrs','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\n 2ndLine 0 to 14yrs\n \n 2020-12-01 10:58:27 UTC\n \n 2020-12-01 12:40: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 1040\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','2020-12-01 12:58:27',4,'2020-12-01 14:40:44',4,0,NULL,NULL,NULL,'05a35dc8-35a8-4594-9194-0d4b6dd486d0'),(1041,'Children ARV Regimen_3rdLine 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 Data Set\n \n 2020-12-01 10:58:32 UTC\n \n 2020-12-01 12: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 1041\n \n \n revised_child_weight\n \n \n \n \n endDate\n ${endDate}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 5a03to3.9\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 revised_child_weight\n 0-3.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 5a04to5.9\n \n \n \n \n revised_child_weight\n 4-5.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 5a06to9.9\n \n \n \n \n revised_child_weight\n 6-9.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 5a10to13.9\n \n \n \n \n revised_child_weight\n 10-13.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 5a14to19.9\n \n \n \n \n revised_child_weight\n 14-19.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 5a20to24.9\n \n \n \n \n revised_child_weight\n 20-24.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 5a25to34.9\n \n \n \n \n revised_child_weight\n 25-34.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 5a35Plus\n \n \n \n \n revised_child_weight\n 35pluskg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 5b03to3.9\n \n \n \n \n \n \n \n \n \n 5b04to5.9\n \n \n \n \n \n \n 5b06to9.9\n \n \n \n \n \n \n 5b10to13.9\n \n \n \n \n \n \n 5b14to19.9\n \n \n \n \n \n \n 5b20to24.9\n \n \n \n \n \n \n 5b25to34.9\n \n \n \n \n \n \n 5b35Plus\n \n \n \n \n \n \n 5c03to3.9\n \n \n \n \n \n \n \n \n \n 5c04to5.9\n \n \n \n \n \n \n 5c06to9.9\n \n \n \n \n \n \n 5c10to13.9\n \n \n \n \n \n \n 5c14to19.9\n \n \n \n \n \n \n 5c20to24.9\n \n \n \n \n \n \n 5c25to34.9\n \n \n \n \n \n \n 5cPlus\n \n \n \n \n \n \n 5d03to3.9\n \n \n \n \n \n \n \n \n \n 5d04to5.9\n \n \n \n \n \n \n 5d06to9.9\n \n \n \n \n \n \n 5d10to13.9\n \n \n \n \n \n \n 5d14to19.9\n \n \n \n \n \n \n 5d20to24.9\n \n \n \n \n \n \n 5d25to34.9\n \n \n \n \n \n \n 5d35Plus\n \n \n \n \n \n \n 5e03to3.9\n \n \n \n \n \n \n \n \n \n 5e04to5.9\n \n \n \n \n \n \n 5e06to9.9\n \n \n \n \n \n \n 5e10to13.9\n \n \n \n \n \n \n 5e14to19.9\n \n \n \n \n \n \n 5e20to24.9\n \n \n \n \n \n \n 5e25to34.9\n \n \n \n \n \n \n 5e35Plus\n \n \n \n \n \n \n 5f03to3.9\n \n \n \n \n \n \n \n \n \n 5f04to5.9\n \n \n \n \n \n \n 5f06to9.9\n \n \n \n \n \n \n 5f10to13.9\n \n \n \n \n \n \n 5f14to19.9\n \n \n \n \n \n \n 5f20to24.9\n \n \n \n \n \n \n 5f25to34.9\n \n \n \n \n \n \n 5f35Plus\n \n \n \n \n \n \n 5g00to3.9\n \n \n \n \n \n \n \n \n \n 5g04to5.9\n \n \n \n \n \n \n 5g06to9.9\n \n \n \n \n \n \n 5g10to13.9\n \n \n \n \n \n \n 5g14to19.9\n \n \n \n \n \n \n 5g20to24.9\n \n \n \n \n \n \n 5g25to34.9\n \n \n \n \n \n \n 5g35Plus\n \n \n \n \n \n \n 5h00to3.9\n \n \n \n \n \n \n \n \n \n 5h04to5.9\n \n \n \n \n \n \n 5h06to9.9\n \n \n \n \n \n \n 5h10to13.9\n \n \n \n \n \n \n 5h14to19.9\n \n \n \n \n \n \n 5h20to24.9\n \n \n \n \n \n \n 5h25to34.9\n \n \n \n \n \n \n 5h35Plus\n \n \n \n \n \n \n','2020-12-01 12:58:32',4,'2020-12-01 14:01:44',4,0,NULL,NULL,NULL,'4af0c854-1dce-4ef5-a7cd-5317a534c373'),(1042,'Children ARV Regimen_3rdLine','3rdLine 0 to 14yrs','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\n 3rdLine 0 to 14yrs\n \n 2020-12-01 12:42:12 UTC\n \n 2020-12-01 12:42: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 1042\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','2020-12-01 14:42:12',4,'2020-12-01 14:42:17',4,0,NULL,NULL,NULL,'80ef520c-2d58-473a-a588-58b182a4dbcb'),(1043,'Children ARV Regimen_3rdLine 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 Data Set\n \n 2020-12-01 12:42:17 UTC\n \n 2020-12-01 13: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 1043\n \n \n revised_child_weight\n \n \n \n \n endDate\n ${endDate}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 6a03to3.9\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 revised_child_weight\n 0-3.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 6a04to5.9\n \n \n \n \n revised_child_weight\n 4-5.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 6a06to9.9\n \n \n \n \n revised_child_weight\n 6-9.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 6a10to13.9\n \n \n \n \n revised_child_weight\n 10-13.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 6a14to19.9\n \n \n \n \n revised_child_weight\n 14-19.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 6a20to24.9\n \n \n \n \n revised_child_weight\n 20-24.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 6a25to34.9\n \n \n \n \n revised_child_weight\n 25-34.9kg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 6a35kgPlus\n \n \n \n \n revised_child_weight\n 35pluskg\n \n \n DM_Age\n Children 0to14\n \n \n \n \n \n 6b00to3.9\n \n \n \n \n \n \n \n \n \n 6b04to5.9\n \n \n \n \n \n \n 6b06to9.9\n \n \n \n \n \n \n 6b10to13.9\n \n \n \n \n \n \n 6b14to19.9\n \n \n \n \n \n \n 6b20to24.9\n \n \n \n \n \n \n 6b25to34.9\n \n \n \n \n \n \n 6b35kgPlus\n \n \n \n \n \n \n 6c00to3.9\n \n \n \n \n \n \n \n \n \n 6c04to5.9\n \n \n \n \n \n \n 6c06to9.9\n \n \n \n \n \n \n 6c10to13.9\n \n \n \n \n \n \n 6c14to19.9\n \n \n \n \n \n \n 6c20to24.9\n \n \n \n \n \n \n 6c25to34.9\n \n \n \n \n \n \n 6c35kgPlus\n \n \n \n \n \n \n 6d00to3.9\n \n \n \n \n \n \n \n \n \n 6d04to5.9\n \n \n \n \n \n \n 6d06to9.9\n \n \n \n \n \n \n 6d10to13.9\n \n \n \n \n \n \n 6d14to19.9\n \n \n \n \n \n \n 6d20to24.9\n \n \n \n \n \n \n 6d25to34.9\n \n \n \n \n \n \n 6d35kgPlus\n \n \n \n \n \n \n 6e00to3.9\n \n \n \n \n \n \n \n \n \n 6e04to5.9\n \n \n \n \n \n \n 6e06to9.9\n \n \n \n \n \n \n 6e10to13.9\n \n \n \n \n \n \n 6e14to19.9\n \n \n \n \n \n \n 6e20to24.9\n \n \n \n \n \n \n 6e25to34.9\n \n \n \n \n \n \n 6e35kgPlus\n \n \n \n \n \n \n 6f00to3.9\n \n \n \n \n \n \n \n \n \n 6f04to5.9\n \n \n \n \n \n \n 6f06to9.9\n \n \n \n \n \n \n 6f10to13.9\n \n \n \n \n \n \n 6f14to19.9\n \n \n \n \n \n \n 6f20to24.9\n \n \n \n \n \n \n 6f25to34.9\n \n \n \n \n \n \n 6f35kgPlus\n \n \n \n \n \n \n','2020-12-01 14:42:17',4,'2020-12-01 15:34:47',4,0,NULL,NULL,NULL,'6ef48774-47bc-4e3e-af6c-6a2b8d77c151'),(1044,'adult_arv_2r_1mnth','adult_arv_2r_1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2r_1mnth\n adult_arv_2r_1mnth\n \n 2020-12-02 17:17:57 UTC\n \n 2021-07-13 14:48: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 1044\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-12-02 17:17:57',4,'2021-07-13 14:48:20',4,0,NULL,NULL,NULL,'28807ad7-020c-4261-84e8-960017de0d3c'),(1045,'adult_arv_2s_3mnths','adult_arv_2s_3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2s_3mnths\n adult_arv_2s_3mnths\n \n 2020-12-02 17:26:50 UTC\n \n 2020-12-02 20:24: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 1045\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-12-02 17:26:50',4,'2020-12-02 20:24:28',4,0,NULL,NULL,NULL,'9508f75e-01d6-4fac-a9ef-701b6306f4e5'),(1046,'adult_arv_2r_3mnths','adult_arv_2r_3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2r_3mnths\n adult_arv_2r_3mnths\n \n 2020-12-02 17:31:00 UTC\n \n 2020-12-02 20:20: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 1046\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-12-02 17:31:00',4,'2020-12-02 20:20:01',4,0,NULL,NULL,NULL,'bcbafe45-287a-4341-8144-75a99f00c1e3'),(1047,'adult_arv_2s_1mnth','adult_arv_2s_1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2s_1mnth\n adult_arv_2s_1mnth\n \n 2020-12-02 20:45:08 UTC\n \n 2021-07-13 14:48: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 1047\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-12-02 20:45:08',4,'2021-07-13 14:48:35',4,0,NULL,NULL,NULL,'2de0ce41-df04-42e8-a72d-64902cad4a98'),(1048,'CMP_ART Regimen 1month supply 2i','CMP_ART Regimen 1month supply 2i','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 2i\n CMP_ART Regimen 1month supply 2i\n \n 2020-12-02 20:46:49 UTC\n \n 2020-12-03 10:49: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 1048\n Clients-newly-initiated-2i OR Clients-seen-given-1-month-supply-2i\n \n \n Clients-newly-initiated-2i\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 Clients-seen-given-1-month-supply-2i\n \n \n \n \n \n \n','2020-12-02 20:46:49',4,'2020-12-03 10:49:09',4,0,NULL,NULL,NULL,'591d048c-3a90-49ac-837e-e10439b8fe82'),(1049,'Clients newly initiated 2i','Clients newly initiated 2i','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated 2i\n Clients newly initiated 2i\n \n 2020-12-02 20:51:46 UTC\n \n 2021-01-27 14:58: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 1049\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 3678 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2020-12-02 20:51:46',4,'2021-01-27 14:58:29',4,0,NULL,NULL,NULL,'3c150559-79b5-49ac-890c-9d5f7a3a20fd'),(1050,'Clients seen given 1 month supply 2i','Clients seen given 1 month supply 2i','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 2i\n Clients seen given 1 month supply 2i\n \n 2020-12-02 20:54:19 UTC\n \n 2021-07-13 14:18: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 1050\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3678)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2020-12-02 20:54:19',4,'2021-07-13 14:18:04',4,0,NULL,NULL,NULL,'baa39d83-3d61-46a8-9c06-28b1090d3b8f'),(1051,'adult_arv_2i_3mnths','adult_arv_2i_3mnths','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2i_3mnths\n adult_arv_2i_3mnths\n \n 2020-12-02 20:58:18 UTC\n \n 2020-12-02 21:01: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 1051\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-12-02 20:58:18',4,'2020-12-02 21:01:13',4,0,NULL,NULL,NULL,'417c4ce0-cb54-449e-ac98-8fc8e138f03d'),(1052,'adult_arv_2i_1mnth','adult_arv_2i_1mnth','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2i_1mnth\n adult_arv_2i_1mnth\n \n 2020-12-02 21:01:50 UTC\n \n 2021-07-13 14: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 1052\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2020-12-02 21:01:50',4,'2021-07-13 14:37:12',4,0,NULL,NULL,NULL,'2e956343-8dfb-46c3-94a6-c9c6f83959a6'),(1053,'Clients given 3 months supply 3a','Clients given 3 months supply 3a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 3a\n Clients given 3 months supply 3a\n \n 2021-01-26 17:32:43 UTC\n \n 2021-01-26 17:33: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 1053\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3683) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3683) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3683) \n \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3683 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-26 17:32:43',4,'2021-01-26 17:33:19',4,0,NULL,NULL,NULL,'bb3bfcea-7bf4-40ff-8e51-c02125d9ed36'),(1054,'Clients given 3 months supply 3b','3mnths 3b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 3b\n 3mnths 3b\n \n 2021-01-26 17:35:11 UTC\n \n 2021-01-26 17:35: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 1054\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3684) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3684) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3684) \n \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3684 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-26 17:35:11',4,'2021-01-26 17:35:48',4,0,NULL,NULL,NULL,'c961ad65-091a-4ef3-b3df-93795215d394'),(1055,'Clients given 3 months supply 3c','3mnths 3c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 3c\n 3mnths 3c\n \n 2021-01-26 17:36:24 UTC\n \n 2021-01-26 17:36: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 1055\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3685) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3685) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3685) \n \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3685 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-26 17:36:24',4,'2021-01-26 17:36:53',4,0,NULL,NULL,NULL,'980ee077-7ac1-4380-b636-b5d83e80e128'),(1056,'Clients given 3 months supply 3d','3mnths 3d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 3d\n 3mnths 3d\n \n 2021-01-26 17:38:04 UTC\n \n 2021-01-26 17:38: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 1056\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4706) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4706) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4706) \n \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4706 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-26 17:38:04',4,'2021-01-26 17:38:37',4,0,NULL,NULL,NULL,'a5671007-d60d-44f4-8e1c-230aeb2239ec'),(1057,'Clients given 3 months supply 3h','3 months 3h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 3 months supply 3h\n 3 months 3h\n \n 2021-01-26 17:44:47 UTC\n \n 2021-01-26 17:45: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 1057\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4177)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4710) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 4710) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4177)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4710) \n \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4177 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4710 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-26 17:44:47',4,'2021-01-26 17:45:17',4,0,NULL,NULL,NULL,'2e7c12e2-5224-464a-b8be-3b2fd231a4e1'),(1058,'Clients given 6 months supply 2i','6mnths 2i','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply 2i\n 6mnths 2i\n \n 2021-01-26 19:06:43 UTC\n \n 2021-01-26 19:07: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 1058\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4247)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3678) \n UNION \n \n (SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id)regimen \n WHERE ARV_regimen = 3678) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -2 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3678) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3678) \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -4 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3678) \n \n \nUNION \n \n(SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n (select distinct o.person_id,o.value_coded current_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n ) \n )currentreg \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as substitute_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n (select distinct o.person_id,o.value_coded as switch_regimen \n FROM obs o \n -- CAME IN PREVIOUS 1 MONTH AND WAS GIVEN (2, 3, 4, 5, 6 MONHTS SUPPLY OF DRUGS) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND o.person_id in ( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -5 MONTH)) \n AND oss.concept_id = 4174 and (oss.value_coded in (4247)) \n ) \n \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n )) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n )regimen \n WHERE ARV_regimen = 3678) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded = 4247 \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -6 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(os.value_datetime, CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and os.obs_datetime <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n \n \n )regimen \n WHERE ARV_regimen = 3678 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and oss.obs_datetime <= CAST(:endDate AS DATE) \n and oss.obs_datetime > DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(os.value_datetime), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and os.obs_datetime <= 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, max(os.value_datetime) 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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-26 19:06:43',4,'2021-01-26 19:07:18',4,0,NULL,NULL,NULL,'826fa67b-2ba1-42de-bbc9-fff95007b9fb'); +INSERT INTO `serialized_object` VALUES (1059,'Clients seen given 1 month supply other','1 month other','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply other\n 1 month other\n \n 2021-01-27 06:50:37 UTC\n \n 2021-07-08 14:19: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 1059\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2143)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 10 AND datediff(latest_follow_up, max_observation)< 28 \n or datediff(latest_follow_up, max_observation) >= 28 AND datediff(latest_follow_up, max_observation)< 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-01-27 06:50:37',4,'2021-07-08 14:19:54',4,0,NULL,NULL,NULL,'aba0cb73-c297-4fba-b97d-89ac9a7c8003'),(1060,'Clients given 6 months supply other','6 months other','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6 months supply other\n 6 months other\n \n 2021-01-27 07:08:38 UTC\n \n 2021-06-30 11:24: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 1060\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2143)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 168 AND datediff(latest_follow_up, max_observation)< 196)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-01-27 07:08:38',4,'2021-06-30 11:24:37',4,0,NULL,NULL,NULL,'2cbd2310-1aec-4bdf-b0e2-6a5387529764'),(1061,'Clients given Other months MMD supply other','other months other regimen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply other\n other months other regimen\n \n 2021-01-27 07:28:16 UTC\n \n 2021-06-30 11:49: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 1061\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 2143)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 AND datediff(latest_follow_up, max_observation)< 140 \n OR datediff(latest_follow_up, max_observation) >= 140 AND datediff(latest_follow_up, max_observation)< 168 \n OR datediff(latest_follow_up, max_observation) >= 196 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-01-27 07:28:16',4,'2021-06-30 11:49:08',4,0,NULL,NULL,NULL,'c51f0308-5026-404c-afbf-35df5fb4e729'),(1062,'Clients newly initiated other regimen','initiated other','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients newly initiated other regimen\n initiated other\n \n 2021-01-27 14:51:15 UTC\n \n 2021-01-27 14:51: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 1062\n select distinct o.person_id \nfrom obs o \n inner join location l on o.location_id = l.location_id \n INNER JOIN person ON person.person_id = o.person_id \n \nwhere (o.location_id =:location or parent_location =:location) \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 AND o.voided = 0 \n \nand o.person_id in( \n select os.person_id \n from obs os \n -- All patients given x regimen during a particular period \n where os.concept_id = 2250 and os.value_coded = 2143 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \n \nand o.person_id not in ( -- remove transfer ins \n select os.person_id \n from obs os \n where os.concept_id = 3634 AND os.value_coded = 2095 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n) \nAND person.voided = 0 \n\n','2021-01-27 14:51:15',4,'2021-01-27 14:51:51',4,0,NULL,NULL,NULL,'83133cb9-2778-43d9-b579-1ad824027608'),(1063,'CMP_ART Regimen 1month supply other','compostion newly initiated and seen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply other\n compostion newly initiated and seen\n \n 2021-01-27 15:28:45 UTC\n \n 2021-01-27 15:32: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 1063\n Clients-seen-given-1-month-supply-other OR Clients-newly-initiated-other-regimen\n \n \n Clients-seen-given-1-month-supply-other\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 Clients-newly-initiated-other-regimen\n \n \n \n \n \n \n','2021-01-27 15:28:45',4,'2021-01-27 15:32:00',4,0,NULL,NULL,NULL,'60b6b073-1a42-4d55-b194-fadbb863aadc'),(1064,'Clients seen given 1 month supply 4g','4g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4g\n 4g\n \n 2021-01-27 21:09:12 UTC\n \n 2021-02-04 07:37: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 1064\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4684) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4684 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:09:12',4,'2021-02-04 07:37:42',4,0,NULL,NULL,NULL,'cfa78680-b638-40d6-bf8a-d6b3e7092725'),(1065,'Clients seen given 1 month supply 4h','4h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4h\n 4h\n \n 2021-01-27 21:10:56 UTC\n \n 2021-02-04 07:38: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 1065\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4685) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4685 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:10:56',4,'2021-02-04 07:38:29',4,0,NULL,NULL,NULL,'8c7bfe6d-17d0-4e79-836b-078e5fb4b7ba'),(1066,'Clients seen given 1 month supply 4j','4j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4j\n 4j\n \n 2021-01-27 21:12:51 UTC\n \n 2021-02-04 07:41: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 1066\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4686) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4686 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:12:51',4,'2021-02-04 07:41:48',4,0,NULL,NULL,NULL,'0d272d06-c49f-42c4-b238-961e4118287a'),(1067,'Clients seen given 1 month supply 4k','4k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4k\n 4k\n \n 2021-01-27 21:14:44 UTC\n \n 2021-02-04 07:42: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 1067\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4687) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4687 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:14:44',4,'2021-02-04 07:42:38',4,0,NULL,NULL,NULL,'358376fd-5341-4dcc-a010-914229961974'),(1068,'Clients seen given 1 month supply 4L','4L','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 4L\n 4L\n \n 2021-01-27 21:16:30 UTC\n \n 2021-02-04 07:43: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 1068\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4688) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4688 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:16:30',4,'2021-02-04 07:43:43',4,0,NULL,NULL,NULL,'5450f823-8f45-49a7-b678-ab36e639003a'),(1069,'Clients seen given 1 month supply 5c','5c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 5c\n 5c\n \n 2021-01-27 21:26:07 UTC\n \n 2021-02-04 07:56: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 1069\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4696) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4696 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:26:07',4,'2021-02-04 07:56:53',4,0,NULL,NULL,NULL,'6c5f0b5e-d8e2-49a5-9add-ea65c07a8043'),(1070,'Clients seen given 1 month supply 5d','5d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 5d\n 5d\n \n 2021-01-27 21:29:58 UTC\n \n 2021-02-04 07:57: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 1070\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4697) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4697 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:29:58',4,'2021-02-04 07:57:57',4,0,NULL,NULL,NULL,'5420e208-15e9-46e3-a657-e923dc3f26be'),(1071,'Clients seen given 1 month supply 5e','5e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 5e\n 5e\n \n 2021-01-27 21:36:15 UTC\n \n 2021-02-04 08:06: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 1071\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4698) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4698 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:36:15',4,'2021-02-04 08:06:05',4,0,NULL,NULL,NULL,'5354f557-775e-4589-81ec-119d69b30474'),(1072,'Clients seen given 1 month supply 5f','5f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 5f\n 5f\n \n 2021-01-27 21:38:31 UTC\n \n 2021-02-04 08:08: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 1072\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4699) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4699 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:38:31',4,'2021-02-04 08:08:14',4,0,NULL,NULL,NULL,'e03d8077-1955-4529-a85b-f0e830a1bc5c'),(1073,'Clients seen given 1 month supply 5g','5g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 5g\n 5g\n \n 2021-01-27 21:40:02 UTC\n \n 2021-02-04 08:09: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 1073\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4700) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4700 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:40:02',4,'2021-02-04 08:09:12',4,0,NULL,NULL,NULL,'4a4bfccf-c6fe-4116-b6d4-53e56823c0be'),(1074,'Clients seen given 1 month supply 5h','5h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 5h\n 5h\n \n 2021-01-27 21:41:41 UTC\n \n 2021-02-04 08:10: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 1074\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4701) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4701 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:41:41',4,'2021-02-04 08:10:05',4,0,NULL,NULL,NULL,'270631db-3551-4e98-bae8-f69b16663145'),(1075,'Clients seen given 1 month supply 6b','6b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 6b\n 6b\n \n 2021-01-27 21:54:50 UTC\n \n 2021-02-04 08: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 1075\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 3687) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 3687 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:54:50',4,'2021-02-04 08:15:00',4,0,NULL,NULL,NULL,'99e92cc7-e9ff-4b77-8b8a-2a0f3f2531d8'),(1076,'Clients seen given 1 month supply 6c','6c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 6c\n 6c\n \n 2021-01-27 21:57:30 UTC\n \n 2021-02-04 08:16: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 1076\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4702) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4702 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 21:57:30',4,'2021-02-04 08:16:11',4,0,NULL,NULL,NULL,'1ba755ee-ec4a-4392-9d48-56e0e1e6f88c'),(1077,'Clients seen given 1 month supply 6d','6d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 6d\n 6d\n \n 2021-01-27 22:01:27 UTC\n \n 2021-02-04 08:17: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 1077\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4703) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4703 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 22:01:27',4,'2021-02-04 08:17:43',4,0,NULL,NULL,NULL,'e58406b7-fa8a-4b5c-ae40-3dddbb28b5f2'),(1078,'Clients seen given 1 month supply 6e','6e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 6e\n 6e\n \n 2021-01-27 22:03:20 UTC\n \n 2021-02-04 08:18: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 1078\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4704) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4704 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 22:03:20',4,'2021-02-04 08:18:35',4,0,NULL,NULL,NULL,'57d769e1-feb2-4a2f-b1ac-b3993f6a984a'),(1079,'Clients seen given 1 month supply 6f','6f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients seen given 1 month supply 6f\n 6f\n \n 2021-01-27 22:04:47 UTC\n \n 2021-02-04 08: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 1079\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 \n(SELECT person_id \nFROM( ( \n SELECT person_id \n FROM( \n SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) as ARV_regimen \n FROM \n ( \n select distinct o.person_id,o.value_coded as current_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2250 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2250 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )currentreg \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as substitute_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 4284 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 4284 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )substitutereg ON currentreg.person_id = substitutereg.person_id \n \n LEFT OUTER JOIN \n ( \n select distinct o.person_id,o.value_coded as switch_regimen \n from obs o \n \n inner join \n (select ob.person_id,cast(max(ob.obs_datetime) as date) maxdate \n from obs ob \n where ob.concept_id = 2268 \n AND cast(ob.obs_datetime as date) <= cast(:endDate as date) \n AND MONTH(ob.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(ob.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and ob.voided = 0 \n group by ob.person_id \n )latest \n on latest.person_id = o.person_id \n \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n INNER JOIN obs os on latest.person_id = os.person_id \n AND o.concept_id = 2268 \n AND o.voided = 0 \n AND (os.concept_id = 4174 AND os.value_coded in (4175,4243)) \n AND os.voided = 0 \n and CAST(o.obs_datetime as date) = maxdate \n and CAST(o.obs_datetime AS DATE) = CAST(os.obs_datetime AS DATE) \n and o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE oss.concept_id = 3843 AND oss.value_coded = 3841 OR oss.value_coded = 3842 \n AND MONTH(oss.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND oss.voided = 0 \n ) \n \n AND o.person_id not in ( \n select oss.person_id \n from obs oss \n -- CLIENTS NEWLY INITIATED ON ART \n WHERE (oss.concept_id = 2249 \n AND MONTH(oss.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(oss.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND oss.voided = 0) \n )switchreg ON currentreg.person_id = switchreg.person_id \n )regimen \n WHERE ARV_regimen = 4705) \nUNION \n \n(SELECT distinct person_id \nFROM(SELECT currentreg.person_id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM(SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2250 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ))currentreg \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 4284 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n ( \n SELECT o.person_id,o.value_coded 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 AND MONTH(o.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(o.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND o.voided = 0 \n AND o.concept_id = 2268 \n AND o.person_id in( \n SELECT oss.person_id \n FROM obs oss \n WHERE MONTH(oss.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(oss.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND oss.concept_id = 4174 and oss.value_coded in (4175,4243) \n AND oss.person_id in ( \n select distinct os.person_id from obs os \n where \n MONTH(os.obs_datetime) = MONTH(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND YEAR(os.obs_datetime) = YEAR(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -1 MONTH)) \n AND os.concept_id = 3752 AND DATEDIFF(CAST(os.value_datetime AS DATE), CAST(:endDate AS DATE)) BETWEEN 0 AND 28 \n ) \n ) \n \n WHERE o.person_id not in ( \n select distinct(person_id) \n from \n ( \n select os.person_id, cast(max(os.obs_datetime) as date) as latest_visit \n from obs os \n where os.concept_id=3843 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n \n ) as visit \n where CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -7 MONTH) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and latest_visit > CAST(o.obs_datetime AS DATE) \n and latest_visit <= CAST(:endDate AS DATE) \n ) \n )switchreg \n ON switchreg.person_id = currentreg.person_id \n )regimen \n WHERE ARV_regimen = 4705 \n) \n \n) AS ARTCurrent_PrevMonths \n \nWHERE ARTCurrent_PrevMonths.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, max(oss.value_datetime) 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 -7 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(max(CAST(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, max(CAST(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 ) \nAND ARTCurrent_PrevMonths.person_id not 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 ) \n \n)\n','2021-01-27 22:04:47',4,'2021-02-04 08:19:20',4,0,NULL,NULL,NULL,'da18d6ab-b020-450f-b2bd-39e1f9f74ba0'),(1080,'CMP_ART Regimen 1month supply 4L','4L','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.CompositionCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CMP_ART Regimen 1month supply 4L\n 4L\n \n 2021-01-28 01:48:55 UTC\n \n 2021-01-28 01:51: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 1080\n Clients-newly-initiated-4L OR Clients-seen-given-1-month-supply-4L\n \n \n Clients-newly-initiated-4L\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 Clients-seen-given-1-month-supply-4L\n \n \n \n \n \n \n','2021-01-28 01:48:55',4,'2021-01-28 01:51:38',4,0,NULL,NULL,NULL,'488bcaf1-af5e-47ff-84a0-8274f96ccb1d'),(1081,'Clients given 4c','All Clients given 4c, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4c\n All Clients given 4c, Seen and MMD\n \n 2021-07-01 09:22:29 UTC\n \n 2021-07-14 09:17: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 1081\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:22:29',4,'2021-07-14 09:17:24',4,0,NULL,NULL,NULL,'9938e191-eb7a-40b5-bb9d-76dde26372f7'),(1082,'Clients given 4d',' All Clients given 4d, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4d\n All Clients given 4d, Seen and MMD\n \n 2021-07-01 09:25:51 UTC\n \n 2021-07-14 09:19: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 1082\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:25:51',4,'2021-07-14 09:19:05',4,0,NULL,NULL,NULL,'8292e011-c883-47e2-8632-c9978c45eca8'),(1083,'Clients given 4e','All Clients given 4e, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4e\n All Clients given 4e, Seen and MMD\n \n 2021-07-01 09:29:32 UTC\n \n 2021-07-14 09:21: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 1083\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:29:32',4,'2021-07-14 09:21:43',4,0,NULL,NULL,NULL,'34ff952a-26df-412d-a502-d6221f35c47e'),(1084,'Clients given 4f','All Clients given 4f, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4f\n All Clients given 4f, Seen and MMD\n \n 2021-07-01 09:30:43 UTC\n \n 2021-07-14 09:22: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 1084\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:30:43',4,'2021-07-14 09:22:26',4,0,NULL,NULL,NULL,'b33afbb9-4ac6-4be4-85e4-a282f8f10217'),(1085,'Clients given 4g','All Clients given 4g, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4g\n All Clients given 4g, Seen and MMD\n \n 2021-07-01 09:31:36 UTC\n \n 2021-07-14 09:24: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 1085\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:31:36',4,'2021-07-14 09:24:27',4,0,NULL,NULL,NULL,'a80b2968-8f65-41f3-881b-f7a0cc83b93a'),(1086,'Clients given 4h','All Clients given 4h, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4h\n All Clients given 4h, Seen and MMD\n \n 2021-07-01 09:32:40 UTC\n \n 2021-07-14 09:30: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 1086\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:32:40',4,'2021-07-14 09:30:42',4,0,NULL,NULL,NULL,'cb49fed7-1491-4877-8963-fdc9f865e0a6'),(1087,'Clients given 4j','All Clients given 4j, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4j\n All Clients given 4j, Seen and MMD\n \n 2021-07-01 09:33:37 UTC\n \n 2021-07-14 09:31: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 1087\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:33:37',4,'2021-07-14 09:31:19',4,0,NULL,NULL,NULL,'b17ab786-8ff7-41d6-8d1f-7e6ad1386455'),(1088,'Clients given 4k','All Clients given 4k, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4k\n All Clients given 4k, Seen and MMD\n \n 2021-07-01 09:34:51 UTC\n \n 2021-07-14 09:32: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 1088\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:34:51',4,'2021-07-14 09:32:01',4,0,NULL,NULL,NULL,'ca02b119-2d87-464d-971b-23560d54934f'),(1089,'Clients given 4L','All Clients given 4L, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L\n All Clients given 4L, Seen and MMD\n \n 2021-07-01 09:35:43 UTC\n \n 2021-07-14 09:34: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 1089\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:35:43',4,'2021-07-14 09:34:14',4,0,NULL,NULL,NULL,'15d2f499-f37c-454b-bdd0-cfdec1a9822e'),(1090,'Clients given 5a','All Clients given 5a, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5a\n All Clients given 5a, Seen and MMD\n \n 2021-07-01 09:36:31 UTC\n \n 2021-07-14 09:35: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 1090\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:36:31',4,'2021-07-14 09:35:49',4,0,NULL,NULL,NULL,'92ff32c5-1f97-40c8-a00e-f5510a1844fe'),(1091,'Clients given 5b','All Clients given 5b, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5b\n All Clients given 5b, Seen and MMD\n \n 2021-07-01 09:37:38 UTC\n \n 2021-07-14 09: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 1091\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:37:38',4,'2021-07-14 09:42:28',4,0,NULL,NULL,NULL,'b673009d-635d-4656-86f4-3e8b333c30c5'),(1092,'Clients given 5c','All Clients given 5c, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5c\n All Clients given 5c, Seen and MMD\n \n 2021-07-01 09:38:32 UTC\n \n 2021-07-14 09:41: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 1092\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:38:32',4,'2021-07-14 09:41:27',4,0,NULL,NULL,NULL,'bfd23091-3c9d-4d67-8499-b0aa368bfb0d'),(1093,'Clients given 5d','All Clients given 5d, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5d\n All Clients given 5d, Seen and MMD\n \n 2021-07-01 09:39:29 UTC\n \n 2021-07-14 09:43: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 1093\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:39:29',4,'2021-07-14 09:43:02',4,0,NULL,NULL,NULL,'8db1f900-d2a1-4ba5-b563-b7daf9022432'),(1094,'Clients given 5e','All Clients given 5e, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5e\n All Clients given 5e, Seen and MMD\n \n 2021-07-01 09:40:22 UTC\n \n 2021-07-14 09:43: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 1094\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:40:22',4,'2021-07-14 09:43:40',4,0,NULL,NULL,NULL,'c00787d2-2c6c-4597-994b-049aad75c1aa'),(1095,'Clients given 5f','All Clients given 5f, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5f\n All Clients given 5f, Seen and MMD\n \n 2021-07-01 09:41:11 UTC\n \n 2021-07-14 09:44: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 1095\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:41:11',4,'2021-07-14 09:44:37',4,0,NULL,NULL,NULL,'09a901cd-d076-4d07-b59e-23721346dab7'),(1096,'Clients given 5g','All Clients given 5g, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5g\n All Clients given 5g, Seen and MMD\n \n 2021-07-01 09:42:14 UTC\n \n 2021-07-14 09:45: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 1096\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:42:14',4,'2021-07-14 09:45:16',4,0,NULL,NULL,NULL,'8263e9c9-9136-42b4-8af1-e0c11cf5a2b5'),(1097,'Clients given 5h','All Clients given 5h, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5h\n All Clients given 5h, Seen and MMD\n \n 2021-07-01 09:45:28 UTC\n \n 2021-07-14 09:46: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 1097\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:45:28',4,'2021-07-14 09:46:20',4,0,NULL,NULL,NULL,'0639ed8d-f2ab-4389-9451-95c9cb8ee20c'),(1098,'Clients given 6a','All Clients given 6a, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6a\n All Clients given 6a, Seen and MMD\n \n 2021-07-01 09:46:22 UTC\n \n 2021-07-14 09:50: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 1098\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:46:22',4,'2021-07-14 09:50:16',4,0,NULL,NULL,NULL,'67fe820f-2c01-4b2a-94bb-93d1544cf719'),(1099,'Clients given 6b','All Clients given 6b, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6b\n All Clients given 6b, Seen and MMD\n \n 2021-07-01 09:47:17 UTC\n \n 2021-07-14 09:50: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 1099\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:47:17',4,'2021-07-14 09:50:37',4,0,NULL,NULL,NULL,'68e1057e-a950-4c30-85d5-51519020a3f7'),(1100,'Clients given 6c','All Clients given 6c, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6c\n All Clients given 6c, Seen and MMD\n \n 2021-07-01 09:48:03 UTC\n \n 2021-07-14 09:51: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 1100\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:48:03',4,'2021-07-14 09:51:11',4,0,NULL,NULL,NULL,'66d5fd18-9b6a-47d6-9c4b-9810d4dd8a6f'),(1101,'Clients given 6d','All Clients given 6d, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6d\n All Clients given 6d, Seen and MMD\n \n 2021-07-01 09:49:08 UTC\n \n 2021-07-14 09:51: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 1101\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:49:08',4,'2021-07-14 09:51:42',4,0,NULL,NULL,NULL,'36889bfc-5c40-43fb-8a08-211c12598e8e'),(1102,'Clients given 6e','All Clients given 6e, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6e\n All Clients given 6e, Seen and MMD\n \n 2021-07-01 09:49:58 UTC\n \n 2021-07-14 09:52: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 1102\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:49:58',4,'2021-07-14 09:52:32',4,0,NULL,NULL,NULL,'05c4c823-7f89-494e-9dc9-c8b64c41023f'),(1103,'Clients given 6f','All Clients given 6f, Seen and MMD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6f\n All Clients given 6f, Seen and MMD\n \n 2021-07-01 09:50:50 UTC\n \n 2021-07-14 09:53: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 1103\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \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 \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 ) \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 \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 \n \n))\n','2021-07-01 09:50:50',4,'2021-07-14 09:53:28',4,0,NULL,NULL,NULL,'1e55140b-a007-456a-a680-a4f9f20a192f'),(1104,'2021_adult_arv_2ndline_regimen','Adult 2nd Line Regimen Report including \"other\" supply duration','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2021_adult_arv_2ndline_regimen\n Adult 2nd Line Regimen Report including "other" supply duration\n \n 2021-07-24 21:08:07 UTC\n \n 2021-07-24 21:08: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 1104\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','2021-07-24 21:08:07',4,'2021-07-24 21:08:14',4,0,NULL,NULL,NULL,'65dc07c7-72f2-48bb-af53-7e978056539c'),(1105,'2021_adult_arv_2ndline_regimen Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2021_adult_arv_2ndline_regimen Data Set\n \n 2021-07-24 21:08:14 UTC\n \n 2021-07-25 00:06: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 1105\n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 2c1month\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_Age\n 15+yrs\n \n \n \n \n \n 2c3months\n \n \n \n \n \n \n \n \n \n 2cOther\n \n \n \n \n \n \n \n \n \n 2d1month\n \n \n \n \n \n \n \n \n \n 2d3months\n \n \n \n \n \n \n \n \n \n 2dOther\n \n \n \n \n \n \n \n \n \n 2e1month\n \n \n \n \n \n \n \n \n \n 2e3months\n \n \n \n \n \n \n \n \n \n 2eOther\n \n \n \n \n \n \n \n \n \n 2f1month\n \n \n \n \n \n \n \n \n \n 2f3months\n \n \n \n \n \n \n \n \n \n 2fOther\n \n \n \n \n \n \n \n \n \n 2g1month\n \n \n \n \n \n \n \n \n \n 2g3months\n \n \n \n \n \n \n \n \n \n 2gOther\n \n \n \n \n \n \n \n \n \n 2h1month\n \n \n \n \n \n \n \n \n \n 2h3months\n \n \n \n \n \n \n \n \n \n 2hOther\n \n \n \n \n \n \n \n \n \n 2i1month\n \n \n \n \n \n \n \n \n \n 2i3months\n \n \n \n \n \n \n \n \n \n 2iOther\n \n \n \n \n \n \n \n \n \n 2j1month\n \n \n \n \n \n \n \n \n \n 2j3months\n \n \n \n \n \n \n \n \n \n 2jOther\n \n \n \n \n \n \n \n \n \n 2k1month\n \n \n \n \n \n \n \n \n \n 2k3months\n \n \n \n \n \n \n \n \n \n 2kOther\n \n \n \n \n \n \n \n \n \n 2l1month\n \n \n \n \n \n \n \n \n \n 2l3months\n \n \n \n \n \n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n 2lOther\n \n \n \n \n \n \n \n \n \n 2m1month\n \n \n \n \n \n \n \n \n \n 2m3months\n \n \n \n \n \n \n \n \n \n 2mOther\n \n \n \n \n \n \n \n \n \n 2n1month\n \n \n \n \n \n \n \n \n \n 2n3months\n \n \n \n \n \n \n \n \n \n 2nOther\n \n \n \n \n \n \n \n \n \n 2o1month\n \n \n \n \n \n \n \n \n \n 2o3months\n \n \n \n \n \n \n \n \n \n 2oOther\n \n \n \n \n \n \n \n \n \n 2p1month\n \n \n \n \n \n \n \n \n \n 2p3months\n \n \n \n \n \n \n \n \n \n 2pOther\n \n \n \n \n \n \n \n \n \n 2q1month\n \n \n \n \n \n \n \n \n \n 2q3months\n \n \n \n \n \n \n \n \n \n 2qOther\n \n \n \n \n \n \n \n \n \n 2r1month\n \n \n \n \n \n \n \n \n \n 2r3months\n \n \n \n \n \n \n \n \n \n 2rOther\n \n \n \n \n \n \n \n \n \n 2s1month\n \n \n \n \n \n \n \n \n \n 2s3months\n \n \n \n \n \n \n \n \n \n 2sOther\n \n \n \n \n \n \n \n \n \n','2021-07-24 21:08:14',4,'2021-07-25 00:06:41',4,0,NULL,NULL,NULL,'63481a60-98f4-448d-b87f-81c26b3428a2'),(1106,'Clients given Other months MMD supply 2i','Clients given Other months MMD supply 2i','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 2i\n Clients given Other months MMD supply 2i\n \n 2021-07-24 22:12:47 UTC\n \n 2021-07-24 22: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 1106\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \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 SEEN 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 \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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3678)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56 AND datediff(latest_follow_up, max_observation)< 84 \n OR datediff(latest_follow_up, max_observation) >= 112 \n )as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:12:47',4,'2021-07-24 22:13:34',4,0,NULL,NULL,NULL,'9a098a70-340d-4abf-8812-e8a7af58e41f'),(1107,'Clients given Other months MMD supply 3a','Clients given Other months MMD supply 3a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 3a\n Clients given Other months MMD supply 3a\n \n 2021-07-24 22:14:16 UTC\n \n 2021-07-25 15:39: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 1107\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3683)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:14:16',4,'2021-07-25 15:39:52',4,0,NULL,NULL,NULL,'1beb1f89-253e-4989-86d6-79519e6d1991'),(1108,'Clients given Other months MMD supply 3b','Clients given Other months MMD supply 3b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 3b\n Clients given Other months MMD supply 3b\n \n 2021-07-24 22:15:29 UTC\n \n 2021-07-25 17:23: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 1108\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3684)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:15:29',4,'2021-07-25 17:23:48',4,0,NULL,NULL,NULL,'0c074440-2184-41fd-a989-cd5eab20e861'),(1109,'Clients given Other months MMD supply 3c','Clients given Other months MMD supply 3c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 3c\n Clients given Other months MMD supply 3c\n \n 2021-07-24 22:17:06 UTC\n \n 2021-07-25 17:24:42 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n 1109\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 3685)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:17:06',4,'2021-07-25 17:24:42',4,0,NULL,NULL,NULL,'8197eb7b-2d9c-4dae-b527-342d7a2fc049'),(1110,'Clients given Other months MMD supply 3d','Clients given Other months MMD supply 3d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 3d\n Clients given Other months MMD supply 3d\n \n 2021-07-24 22:17:16 UTC\n \n 2021-07-25 17:25: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 1110\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4706)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:17:16',4,'2021-07-25 17:25:45',4,0,NULL,NULL,NULL,'6e1a7efa-9a36-440e-8fce-17afb7d33a70'),(1111,'Clients given Other months MMD supply 3e','Clients given Other months MMD supply 3e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 3e\n Clients given Other months MMD supply 3e\n \n 2021-07-24 22:17:25 UTC\n \n 2021-07-25 17:26: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 1111\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4707)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:17:25',4,'2021-07-25 17:26:26',4,0,NULL,NULL,NULL,'7f6ea741-a3bf-4488-a354-9a258d65d49d'),(1112,'Clients given Other months MMD supply 3f','Clients given Other months MMD supply 3f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 3f\n Clients given Other months MMD supply 3f\n \n 2021-07-24 22:17:38 UTC\n \n 2021-07-25 15:41: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 1112\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4708)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:17:38',4,'2021-07-25 15:41:48',4,0,NULL,NULL,NULL,'2e6f05f5-2959-48b1-95e6-82ce7fbe83c2'),(1113,'Clients given Other months MMD supply 3g','Clients given Other months MMD supply 3g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 3g\n Clients given Other months MMD supply 3g\n \n 2021-07-24 22:17:47 UTC\n \n 2021-07-25 17: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 1113\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4709)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:17:47',4,'2021-07-25 17:27:36',4,0,NULL,NULL,NULL,'6374a1da-a30b-4a63-8199-c4c44b3b8221'),(1114,'Clients given Other months MMD supply 3h','Clients given Other months MMD supply 3h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given Other months MMD supply 3h\n Clients given Other months MMD supply 3h\n \n 2021-07-24 22:17:57 UTC\n \n 2021-07-25 17:28: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 1114\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 \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id \n \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 patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n \n) AS Clients_Seen \n \nWHERE 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 \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 \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 \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 ) \n ) \n) \n \nUNION \n \n(SELECT Id \n FROM \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.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 \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 ) \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 \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 = 4710)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (select Id, latest_follow_up,max_observation \n FROM( \n select a.person_id AS Id, SUBSTRING(MAX(CONCAT(a.obs_datetime, b.value_datetime)), 20) AS latest_follow_up, Max(CAST(a.obs_datetime AS DATE)) as max_observation, \n SUBSTRING(MAX(CONCAT(a.obs_datetime, b.obs_group_id)), 20) as max_obs_group_id \n from obs a, obs b \n where a.person_id = b.person_id \n and a.concept_id = 3753 \n and b.concept_id = 3752 \n and a.obs_id = b.obs_group_id \n and a.obs_datetime <= cast(:endDate as date) \n group by a.person_id)as latest_follow_up_obs \n where datediff(latest_follow_up, max_observation) >= 56)as supply_duration \n ON Active_Patients.Id = supply_duration.Id \n \n))\n','2021-07-24 22:17:57',4,'2021-07-25 17:28:30',4,0,NULL,NULL,NULL,'e46ed914-5afc-4fe5-ac10-9380c044140d'),(1115,'adult_arv_2c_other','2c other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2c_other\n 2c other months\n \n 2021-07-24 22:39:05 UTC\n \n 2021-07-24 22: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 1115\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:39:05',4,'2021-07-24 22:42:43',4,0,NULL,NULL,NULL,'bb9efe71-8a37-4920-8337-8b62d6bd950f'),(1116,'adult_arv_2d_other','2d other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2d_other\n 2d other months\n \n 2021-07-24 22:44:29 UTC\n \n 2021-07-24 22:45: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 1116\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:44:29',4,'2021-07-24 22:45:24',4,0,NULL,NULL,NULL,'995e2f09-0737-451b-bdc6-e2c3c984506d'),(1117,'adult_arv_2e_other','2e other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2e_other\n 2e other months\n \n 2021-07-24 22:46:28 UTC\n \n 2021-07-24 22:47: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 1117\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:46:28',4,'2021-07-24 22:47:20',4,0,NULL,NULL,NULL,'e8a532b2-29ed-4684-b720-9a676e27d3e3'),(1118,'adult_arv_2f_other','2f other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2f_other\n 2f other months\n \n 2021-07-24 22:48:05 UTC\n \n 2021-07-24 22:49: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 1118\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:48:05',4,'2021-07-24 22:49:00',4,0,NULL,NULL,NULL,'49044e15-08f6-49d8-8286-b490a18b84cc'),(1119,'adult_arv_2g_other','2g other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2g_other\n 2g other months\n \n 2021-07-24 22:49:33 UTC\n \n 2021-07-24 22:50: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 1119\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:49:33',4,'2021-07-24 22:50:25',4,0,NULL,NULL,NULL,'1fa9b60f-c81a-4db8-8c5c-37f4171488ab'),(1120,'adult_arv_2h_other','2h other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2h_other\n 2h other months\n \n 2021-07-24 22:50:50 UTC\n \n 2021-07-24 22:51: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 1120\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:50:50',4,'2021-07-24 22:51:47',4,0,NULL,NULL,NULL,'31df4ed6-1c06-4b03-b057-18f98d16e86d'),(1121,'adult_arv_2i_other','2i other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2i_other\n 2i other months\n \n 2021-07-24 22:52:21 UTC\n \n 2021-07-24 22: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 1121\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:52:21',4,'2021-07-24 22:53:20',4,0,NULL,NULL,NULL,'3115d4f6-4fdf-4376-9e35-fa9a056fd8ba'),(1122,'adult_arv_2j_other','2j other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2j_other\n 2j other months\n \n 2021-07-24 22:55:26 UTC\n \n 2021-07-24 22:56: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 1122\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:55:26',4,'2021-07-24 22:56:15',4,0,NULL,NULL,NULL,'3c32b136-f8bc-4f36-9df9-462b98caa9df'),(1123,'adult_arv_2k_other','2k other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2k_other\n 2k other months\n \n 2021-07-24 22:56:42 UTC\n \n 2021-07-24 22:57: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 1123\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:56:42',4,'2021-07-24 22:57:38',4,0,NULL,NULL,NULL,'eeaf0be9-720b-4017-85c8-8c4c66751aa0'),(1124,'adult_arv_2L_other','2L other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2L_other\n 2L other months\n \n 2021-07-24 22:58:13 UTC\n \n 2021-07-24 22: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 1124\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:58:13',4,'2021-07-24 22:59:11',4,0,NULL,NULL,NULL,'6b8264e4-47f3-4097-9f2f-9c753da5d2eb'),(1125,'adult_arv_2m_other','2m other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2m_other\n 2m other months\n \n 2021-07-24 22:59:40 UTC\n \n 2021-07-24 23: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 1125\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 22:59:40',4,'2021-07-24 23:00:31',4,0,NULL,NULL,NULL,'328d6fe0-827b-43ed-9547-2b8a171b8d37'),(1126,'adult_arv_2n_other','2n other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2n_other\n 2n other months\n \n 2021-07-24 23:01:01 UTC\n \n 2021-07-24 23:01: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 1126\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 23:01:01',4,'2021-07-24 23:01:49',4,0,NULL,NULL,NULL,'eb60c530-b24b-4abb-b0ea-c24552bfe2bc'),(1127,'adult_arv_2o_other','2o other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2o_other\n 2o other months\n \n 2021-07-24 23:02:19 UTC\n \n 2021-07-24 23: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 1127\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 23:02:19',4,'2021-07-24 23:03:14',4,0,NULL,NULL,NULL,'cb68b1db-7af4-458b-b7da-976df2a7ff5c'),(1128,'adult_arv_2p_other','2p other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2p_other\n 2p other months\n \n 2021-07-24 23:03:49 UTC\n \n 2021-07-24 23: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 1128\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 23:03:49',4,'2021-07-24 23:04:47',4,0,NULL,NULL,NULL,'b5ebac06-f1eb-4b1d-b845-1b3189d41a19'),(1129,'adult_arv_2q_other','2q other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2q_other\n 2q other months\n \n 2021-07-24 23:05:21 UTC\n \n 2021-07-24 23:06: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 1129\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 23:05:21',4,'2021-07-24 23:06:14',4,0,NULL,NULL,NULL,'6a8d6891-b916-407b-8b79-81dc51764f86'),(1130,'adult_arv_2r_other','2r other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2r_other\n 2r other months\n \n 2021-07-24 23:06:40 UTC\n \n 2021-07-24 23:09: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 1130\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 23:06:40',4,'2021-07-24 23:09:31',4,0,NULL,NULL,NULL,'7fbbc619-a1f7-4826-b0f1-e97ddbbc0b71'),(1131,'adult_arv_2s_other','2s other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n adult_arv_2s_other\n 2s other months\n \n 2021-07-24 23:10:01 UTC\n \n 2021-07-24 23:12: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 1131\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-24 23:10:01',4,'2021-07-24 23:12:22',4,0,NULL,NULL,NULL,'eb4df91c-f55d-40ab-bd9c-de172dc40fb3'),(1132,' CI20b: Adult 3rd Line other months supply 3a','3a other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI20b: Adult 3rd Line other months supply 3a\n 3a other months\n \n 2021-07-25 17:30:04 UTC\n \n 2021-07-25 17:37: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 1132\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-25 17:30:04',4,'2021-07-25 17:37:28',4,0,NULL,NULL,NULL,'08c4ce55-b96a-4f36-8102-3d1ce8f756df'),(1133,' CI21b: Adult 3rd Line other months supply 3b','3b other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI21b: Adult 3rd Line other months supply 3b\n 3b other months\n \n 2021-07-25 17:38:59 UTC\n \n 2021-07-25 17:40: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 1133\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-25 17:38:59',4,'2021-07-25 17:40:05',4,0,NULL,NULL,NULL,'93f9b74b-83a0-4f9b-a8a6-f2c849d7cad9'),(1134,'CI22b: Adult 3rd Line other months supply 3c','3c other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI22b: Adult 3rd Line other months supply 3c\n 3c other months\n \n 2021-07-25 17:41:04 UTC\n \n 2021-07-25 17:42: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 1134\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-25 17:41:04',4,'2021-07-25 17:42:04',4,0,NULL,NULL,NULL,'8953f6bf-99ef-4f9b-b62e-71aa6658d8d6'),(1135,' CI40b: Adult 3rd Line other months supply 3d','3d other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI40b: Adult 3rd Line other months supply 3d\n 3d other months\n \n 2021-07-25 17:54:44 UTC\n \n 2021-07-25 17: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 1135\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-25 17:54:44',4,'2021-07-25 17:55:29',4,0,NULL,NULL,NULL,'0e2ae3a1-7e4a-4daf-b45e-0d56d09857f5'),(1136,'CI41b: Adult 3rd Line other months supply 3e','3e other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI41b: Adult 3rd Line other months supply 3e\n 3e other months\n \n 2021-07-25 17:56:28 UTC\n \n 2021-07-25 17:57: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 1136\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-25 17:56:28',4,'2021-07-25 17:57:31',4,0,NULL,NULL,NULL,'05be785f-976a-4fd6-939a-848136cddff7'),(1137,' CI42b: Adult 3rd Line other months supply 3f','3f other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI42b: Adult 3rd Line other months supply 3f\n 3f other months\n \n 2021-07-25 17:58:16 UTC\n \n 2021-07-25 17:59: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 1137\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-25 17:58:16',4,'2021-07-25 17:59:08',4,0,NULL,NULL,NULL,'211858e4-23d9-4138-9e74-5204b3a621fa'),(1138,'CI43b: Adult 3rd Line other months supply 3g','3g other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI43b: Adult 3rd Line other months supply 3g\n 3g other months\n \n 2021-07-25 17:59:56 UTC\n \n 2021-07-25 18: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 1138\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-25 17:59:56',4,'2021-07-25 18:00:42',4,0,NULL,NULL,NULL,'0aafe8ee-3a67-4d76-a457-c5ca4d7858bf'),(1139,'CI44b: Adult 3rd Line other months supply 3h','3h other months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI44b: Adult 3rd Line other months supply 3h\n 3h other months\n \n 2021-07-25 18:01:42 UTC\n \n 2021-07-25 18:02: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 1139\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-07-25 18:01:42',4,'2021-07-25 18:02:38',4,0,NULL,NULL,NULL,'3abd957f-7936-4ee4-83e7-315a78da3dd4'),(1140,'2021_adult_arv_3rdline_regimen','Adult 3rd Line Regimen Report including \"other\" supply duration','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2021_adult_arv_3rdline_regimen\n Adult 3rd Line Regimen Report including "other" supply duration\n \n 2021-07-25 18:05:12 UTC\n \n 2021-07-25 18:05: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 1140\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','2021-07-25 18:05:12',4,'2021-07-25 18:05:19',4,0,NULL,NULL,NULL,'d91aae02-390f-4f91-9b6f-ff17d9b03fc5'),(1141,'2021_adult_arv_3rdline_regimen Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 2021_adult_arv_3rdline_regimen Data Set\n \n 2021-07-25 18:05:19 UTC\n \n 2021-07-25 18:15: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 1141\n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 3a_Other\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_Age\n 15+yrs\n \n \n \n \n \n 3a1mnth\n \n \n \n \n \n \n \n \n \n 3b_Other\n \n \n \n \n \n \n \n \n \n 3b1month\n \n \n \n \n \n \n \n \n \n 3c_Other\n \n \n \n \n \n \n \n \n \n 3c1month\n \n \n \n \n \n \n \n \n \n 3d_Other\n \n \n \n \n \n \n \n \n \n 3d1month\n \n \n \n \n \n \n \n \n \n 3e_Other\n \n \n \n \n \n \n \n \n \n 3e1month\n \n \n \n \n \n \n \n \n \n 3f_Other\n \n \n \n \n \n \n \n \n \n 3f1month\n \n \n \n \n \n \n \n \n \n 3g_Other\n \n \n \n \n \n \n \n \n \n 3g1month\n \n \n \n \n \n \n \n \n \n 3h_Other\n \n \n \n \n \n \n \n \n \n 3h1month\n \n \n \n \n \n \n \n \n \n','2021-07-25 18:05:19',4,'2021-07-25 18:15:08',4,0,NULL,NULL,NULL,'67697a30-c7a6-4e60-bb91-cd5e5a4f779e'),(1142,'VL-01 Routine VL tests performed','Total number of VL test results received','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-01 Routine VL tests performed\n Total number of VL test results received\n \n 2021-08-05 12:20:57 UTC\n \n 2021-08-05 12: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 1142\n SELECT person_id \nFROM \n( \n select distinct o.person_id, \n IF(latest_vl_result = 4264, 'LessThan20', IF(latest_vl_result = 4263, 'Undetectable', latest_numeric_vl_result)) AS VL_Result, \n IF(latest_indication_vl = 4281, 'Routine', 'Targeted') as Indication \n \n from obs o INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 4266 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_latest on o.person_id = obs_vl_latest.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n LEFT JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_numeric)), 20) AS latest_numeric_vl_result \n from obs oss \n where oss.concept_id = 2254 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_numeric_latest on o.person_id = obs_vl_numeric_latest.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed \nwhere Indication = 'Routine'\n','2021-08-05 17:50:57',4,'2021-08-05 17:51:13',4,0,NULL,NULL,NULL,'76c4f7ee-6714-44d0-a8e6-33410c683785'),(1143,'VL-02 Routine suppressed VL test results','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-02 Routine suppressed VL test results\n \n \n 2021-08-05 12:22:16 UTC\n \n 2024-02-05 19: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 1143\n SELECT person_id \nFROM \n( \n select distinct o.person_id \n \n from obs o \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- lessThan20 \n where oss.concept_id = 4266 and oss.value_coded = 4264 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LessThan20 \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- lUndetectable \n where oss.concept_id = 4266 and oss.value_coded = 4263 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LessThan20 \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- less than 1000 copies \n where oss.concept_id = 4266 and oss.value_coded = 4265 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.person_id in \n ( \n select person_id \n from obs o \n where o.concept_id = 2254 \n and o.value_numeric < 1000 \n ) \n group by oss.person_id \n \n ) As LessThan1000copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5485 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.value_numeric < 1000 \n group by oss.person_id \n \n ) As Lab_Copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5489 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LDL \n \n order by Id \n \n ) as obs_vl_latest \n on obs_vl_latest.Id = o.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.value_coded = 4281 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 17:52:16',4,'2024-02-06 01:15:51',4,0,NULL,NULL,NULL,'b38f5df3-b850-40c3-9de4-28ac12061621'),(1144,'VL-03 Routine detectable VL test results','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-03 Routine detectable VL test results\n \n \n 2021-08-05 12:23:24 UTC\n \n 2024-02-05 19:49: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 1144\n SELECT person_id \nFROM \n( \n select distinct o.person_id \n \n from obs o \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- More than 1000 copies \n where oss.concept_id = 4266 and oss.value_coded = 4265 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.person_id in \n ( \n select person_id \n from obs o \n where o.concept_id = 2254 \n and o.value_numeric > 1000 \n ) \n group by oss.person_id \n \n ) As MoreThan1000copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5485 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.value_numeric > 1000 \n group by oss.person_id \n \n ) As Lab_Copies \n \n order by Id \n \n ) as obs_vl_latest \n on obs_vl_latest.Id = o.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.value_coded = 4281 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 17:53:24',4,'2024-02-06 01:19:06',4,0,NULL,NULL,NULL,'6597528a-3622-4020-a187-80f96ded9817'),(1145,'VL-04 Targeted VL tests performed','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-04 Targeted VL tests performed\n \n \n 2021-08-05 12:24:38 UTC\n \n 2021-08-05 12:24: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 1145\n SELECT person_id \nFROM \n( \n select distinct o.person_id, \n IF(latest_vl_result = 4264, 'LessThan20', IF(latest_vl_result = 4263, 'Undetectable', latest_numeric_vl_result)) AS VL_Result, \n IF(latest_indication_vl = 4281, 'Routine', 'Targeted') as Indication \n \n from obs o INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 4266 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_latest on o.person_id = obs_vl_latest.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n LEFT JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_numeric)), 20) AS latest_numeric_vl_result \n from obs oss \n where oss.concept_id = 2254 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_numeric_latest on o.person_id = obs_vl_numeric_latest.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed \nwhere Indication = 'Targeted'\n','2021-08-05 17:54:38',4,'2021-08-05 17:54:54',4,0,NULL,NULL,NULL,'7a0d9c5b-e86d-4c06-8e83-487fc8f9238c'),(1146,'VL-05 Targeted suppressed VL test results','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-05 Targeted suppressed VL test results\n \n \n 2021-08-05 12:25:43 UTC\n \n 2024-02-05 19:47: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 1146\n SELECT person_id \nFROM \n( \n select distinct o.person_id \n \n from obs o \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- lessThan20 \n where oss.concept_id = 4266 and oss.value_coded = 4264 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LessThan20 \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- lUndetectable \n where oss.concept_id = 4266 and oss.value_coded = 4263 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LessThan20 \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- less than 1000 copies \n where oss.concept_id = 4266 and oss.value_coded = 4265 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.person_id in \n ( \n select person_id \n from obs o \n where o.concept_id = 2254 \n and o.value_numeric < 1000 \n ) \n group by oss.person_id \n \n ) As LessThan1000copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5485 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.value_numeric < 1000 \n group by oss.person_id \n \n ) As Lab_Copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5489 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LDL \n \n order by Id \n \n ) as obs_vl_latest \n on obs_vl_latest.Id = o.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.value_coded = 4282 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 17:55:43',4,'2024-02-06 01:17:08',4,0,NULL,NULL,NULL,'ca8302ef-0acb-4fa6-9767-2e228b2423c3'),(1147,'VL-06 Targeted detectable VL test results','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-06 Targeted detectable VL test results\n \n \n 2021-08-05 12:26:58 UTC\n \n 2024-02-05 19:50: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 1147\n SELECT person_id \nFROM \n( \n select distinct o.person_id \n \n from obs o \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- More than 1000 copies \n where oss.concept_id = 4266 and oss.value_coded = 4265 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.person_id in \n ( \n select person_id \n from obs o \n where o.concept_id = 2254 \n and o.value_numeric > 1000 \n ) \n group by oss.person_id \n \n ) As MoreThan1000copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5485 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.value_numeric > 1000 \n group by oss.person_id \n \n ) As Lab_Copies \n \n order by Id \n \n ) as obs_vl_latest \n on obs_vl_latest.Id = o.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.value_coded = 4282 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 17:56:58',4,'2024-02-06 01:20:01',4,0,NULL,NULL,NULL,'13d934cf-bdf0-4ac9-a4e4-fe9deda7168e'),(1148,'VL-10 Pregnant Women VL tests performed','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-10 Pregnant Women VL tests performed\n \n \n 2021-08-05 12:28:31 UTC\n \n 2024-02-05 19:07: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 1148\n SELECT person_id \nFROM \n( \n select distinct o.person_id, \n IF(latest_indication_vl = 4281, 'Routine', 'Targeted') as Indication \n \n from obs o INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_draw \n from obs oss \n where oss.concept_id = 4276 and oss.value_coded = 4277 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_latest on o.person_id = obs_vl_latest.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.encounter_id )), 20) AS latest_pregnancy_status \n from obs oss \n where oss.concept_id = 4278 and oss.value_coded = 2146 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) as obs_latest_pregnant_status on o.person_id = obs_latest_pregnant_status.person_id \n \n) as all_vl_tests_performed\n','2021-08-05 17:58:31',4,'2024-02-06 00:37:50',4,0,NULL,NULL,NULL,'9bc3c3e8-f637-4eac-b2e3-1b185917d8bf'),(1149,'VL-11 Pregnant women suppressed VL test results','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-11 Pregnant women suppressed VL test results\n \n \n 2021-08-05 12:29:56 UTC\n \n 2024-02-05 19:33: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 1149\n SELECT person_id \nFROM \n( \n select distinct o.person_id \n \n from obs o \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- lessThan20 \n where oss.concept_id = 4266 and oss.value_coded = 4264 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LessThan20 \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- lUndetectable \n where oss.concept_id = 4266 and oss.value_coded = 4263 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LessThan20 \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- less than 1000 copies \n where oss.concept_id = 4266 and oss.value_coded = 4265 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.person_id in \n ( \n select person_id \n from obs o \n where o.concept_id = 2254 \n and o.value_numeric < 1000 \n ) \n group by oss.person_id \n \n ) As LessThan1000copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5485 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.value_numeric < 1000 \n group by oss.person_id \n \n ) As Lab_Copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5489 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LDL \n \n order by Id \n \n ) as obs_vl_latest \n on obs_vl_latest.Id = o.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.encounter_id )), 20) AS latest_pregnancy_status \n from obs oss \n where oss.concept_id = 4278 and oss.value_coded = 2146 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) as obs_latest_breast_feeding_status on o.person_id = obs_latest_breast_feeding_status.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 17:59:56',4,'2024-02-06 01:03:46',4,0,NULL,NULL,NULL,'860d6c29-dccc-4e19-912f-60271aba1034'),(1150,'VL-12 Pregnant women detectable VL test results','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-12 Pregnant women detectable VL test results\n \n \n 2021-08-05 12:31:45 UTC\n \n 2024-02-05 19:37: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 1150\n SELECT person_id \nFROM \n( \n select distinct o.person_id \n \n from obs o \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- More than 1000 copies \n where oss.concept_id = 4266 and oss.value_coded = 4265 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.person_id in \n ( \n select person_id \n from obs o \n where o.concept_id = 2254 \n and o.value_numeric > 1000 \n ) \n group by oss.person_id \n \n ) As MoreThan1000copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5485 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.value_numeric > 1000 \n group by oss.person_id \n \n ) As Lab_Copies \n \n order by Id \n \n ) as obs_vl_latest \n on obs_vl_latest.Id = o.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.encounter_id )), 20) AS latest_pregnancy_status \n from obs oss \n where oss.concept_id = 4278 and oss.value_coded = 2146 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) as obs_latest_breast_feeding_status on o.person_id = obs_latest_breast_feeding_status.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 18:01:45',4,'2024-02-06 01:07:45',4,0,NULL,NULL,NULL,'f08fe06d-88e4-404b-baba-065c9f71a48e'),(1151,'VL-13 Breastfeeding mothers VL tests performed','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-13 Breastfeeding mothers VL tests performed\n \n \n 2021-08-05 12:32:45 UTC\n \n 2024-02-05 18:33: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 1151\n SELECT person_id \nFROM \n( \n select distinct o.person_id, \n IF(latest_indication_vl = 4281, 'Routine', 'Targeted') as Indication \n \n from obs o INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_draw \n from obs oss \n where oss.concept_id = 4276 and oss.value_coded = 4277 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_latest on o.person_id = obs_vl_latest.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.encounter_id )), 20) AS latest_pregnancy_status \n from obs oss \n where oss.concept_id = 4279 and oss.value_coded = 2146 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) as obs_latest_breast_feeding_status on o.person_id = obs_latest_breast_feeding_status.person_id \n \n) as all_vl_tests_performed\n','2021-08-05 18:02:45',4,'2024-02-06 00:03:06',4,0,NULL,NULL,NULL,'86b11e45-84ca-453b-98db-20eec3fd63f0'),(1152,'VL-14 Breastfeeding mothers suppressed VL test','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-14 Breastfeeding mothers suppressed VL test\n \n \n 2021-08-05 12:33:53 UTC\n \n 2024-02-05 11:52: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 1152\n SELECT person_id \nFROM \n( \n select distinct o.person_id \n \n from obs o \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- lessThan20 \n where oss.concept_id = 4266 and oss.value_coded = 4264 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LessThan20 \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- lUndetectable \n where oss.concept_id = 4266 and oss.value_coded = 4263 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LessThan20 \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- less than 1000 copies \n where oss.concept_id = 4266 and oss.value_coded = 4265 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.person_id in \n ( \n select person_id \n from obs o \n where o.concept_id = 2254 \n and o.value_numeric < 1000 \n ) \n group by oss.person_id \n \n ) As LessThan1000copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5485 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.value_numeric < 1000 \n group by oss.person_id \n \n ) As Lab_Copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5489 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) As LDL \n \n order by Id \n \n ) as obs_vl_latest \n on obs_vl_latest.Id = o.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.encounter_id )), 20) AS latest_pregnancy_status \n from obs oss \n where oss.concept_id = 4279 and oss.value_coded = 2146 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) as obs_latest_breast_feeding_status on o.person_id = obs_latest_breast_feeding_status.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 18:03:53',4,'2024-02-05 17:22:54',4,0,NULL,NULL,NULL,'6b3c185a-0f25-4540-a61b-aaa9310f3fc5'),(1153,'VL-15 Breastfeeding mothers detectable VL test','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-15 Breastfeeding mothers detectable VL test\n \n \n 2021-08-05 12:35:21 UTC\n \n 2024-02-05 18:46: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 1153\n SELECT person_id \nFROM \n( \n select distinct o.person_id \n \n from obs o \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n -- More than 1000 copies \n where oss.concept_id = 4266 and oss.value_coded = 4265 \n and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.person_id in \n ( \n select person_id \n from obs o \n where o.concept_id = 2254 \n and o.value_numeric > 1000 \n ) \n group by oss.person_id \n \n ) As MoreThan1000copies \n \n UNION \n \n select Id, max_observation,latest_vl_result \n from(select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.concept_id)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 5485 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n and oss.value_numeric > 1000 \n group by oss.person_id \n \n ) As Lab_Copies \n \n order by Id \n \n ) as obs_vl_latest \n on obs_vl_latest.Id = o.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.encounter_id )), 20) AS latest_pregnancy_status \n from obs oss \n where oss.concept_id = 4279 and oss.value_coded = 2146 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n \n ) as obs_latest_breast_feeding_status on o.person_id = obs_latest_breast_feeding_status.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 18:05:21',4,'2024-02-06 00:16:38',4,0,NULL,NULL,NULL,'555e193a-3906-4920-98a4-f0b9c90d46df'),(1154,'VL-19 Clients with VL results received during reporting period','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-19 Clients with VL results received during reporting period\n \n \n 2021-08-05 12:36:45 UTC\n \n 2024-02-06 09:08: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 1154\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nwhere o.concept_id = 5494 \n and date(o.value_datetime) between cast(:startDate as date) and cast(:endDate as date) \n and (o.location_id = :location or parent_location = :location) \n and o.voided = 0\n','2021-08-05 18:06:45',4,'2024-02-06 14:38:08',4,0,NULL,NULL,NULL,'52f9140f-67e6-46d2-bf3b-d7a2b1654d94'),(1155,'VL-22 VL tests performed','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-22 VL tests performed\n \n \n 2021-08-05 12:38:45 UTC\n \n 2021-08-05 12:39: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 1155\n SELECT person_id \nFROM \n( \n select distinct o.person_id, \n IF(latest_vl_result = 4264, 'LessThan20', IF(latest_vl_result = 4263, 'Undetectable', latest_numeric_vl_result)) AS VL_Result, \n IF(latest_indication_vl = 4281, 'Routine', 'Targeted') as Indication \n \n from obs o INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 4266 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_latest on o.person_id = obs_vl_latest.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n LEFT JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_numeric)), 20) AS latest_numeric_vl_result \n from obs oss \n where oss.concept_id = 2254 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_numeric_latest on o.person_id = obs_vl_numeric_latest.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed\n','2021-08-05 18:08:45',4,'2021-08-05 18:09:05',4,0,NULL,NULL,NULL,'c228ed83-7fb8-4b0b-9345-3c9ec1e2ef70'),(1156,'VL-23 Suppressed VL test results','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-23 Suppressed VL test results\n \n \n 2021-08-05 12:41:47 UTC\n \n 2021-08-05 12:42: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 1156\n SELECT person_id \nFROM \n( \n select distinct o.person_id, \n IF(latest_vl_result = 4264, 'LessThan20', IF(latest_vl_result = 4263, 'Undetectable', latest_numeric_vl_result)) AS VL_Result, \n IF(latest_indication_vl = 4281, 'Routine', 'Targeted') as Indication \n \n from obs o INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 4266 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_latest on o.person_id = obs_vl_latest.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n LEFT JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_numeric)), 20) AS latest_numeric_vl_result \n from obs oss \n where oss.concept_id = 2254 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND CAST(:endDate AS DATE) \n group by oss.person_id \n having latest_numeric_vl_result < 1000 \n ) as obs_vl_numeric_latest on o.person_id = obs_vl_numeric_latest.person_id \n INNER JOIN person ON person.person_id = o.person_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 \n) as all_vl_tests_performed \nwhere VL_Result is not null\n','2021-08-05 18:11:47',4,'2021-08-05 18:12:02',4,0,NULL,NULL,NULL,'11240ecc-df99-4519-81df-5bf965d2a5e3'),(1157,'VL-24 Detectable VL test results','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-24 Detectable VL test results\n \n \n 2021-08-05 12:43:11 UTC\n \n 2021-08-05 12: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 1157\n SELECT person_id \nFROM \n( \n select distinct o.person_id, \n IF(latest_vl_result = 4264, 'LessThan20', IF(latest_vl_result = 4263, 'Undetectable', latest_numeric_vl_result)) AS VL_Result, \n IF(latest_indication_vl = 4281, 'Routine', 'Targeted') as Indication \n \n from obs o INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 4266 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_latest on o.person_id = obs_vl_latest.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n LEFT JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_numeric)), 20) AS latest_numeric_vl_result \n from obs oss \n where oss.concept_id = 2254 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_numeric_latest on o.person_id = obs_vl_numeric_latest.person_id \n INNER JOIN person ON person.person_id = o.person_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) as all_vl_tests_performed \nwhere person_id not in ( \n SELECT person_id \n FROM \n ( \n select distinct o.person_id, \n IF(latest_vl_result = 4264, 'LessThan20', IF(latest_vl_result = 4263, 'Undetectable', latest_numeric_vl_result)) AS VL_Result, \n IF(latest_indication_vl = 4281, 'Routine', 'Targeted') as Indication \n \n from obs o INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_vl_result \n from obs oss \n where oss.concept_id = 4266 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_vl_latest on o.person_id = obs_vl_latest.person_id \n INNER JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS latest_indication_vl \n from obs oss \n where oss.concept_id = 4280 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id \n ) as obs_routine_latest_vl on o.person_id = obs_routine_latest_vl.person_id \n LEFT JOIN \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_numeric)), 20) AS latest_numeric_vl_result \n from obs oss \n where oss.concept_id = 2254 and oss.voided=0 \n and oss.obs_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH)) AND CAST(:endDate AS DATE) \n group by oss.person_id \n having latest_numeric_vl_result < 1000 \n ) as obs_vl_numeric_latest on o.person_id = obs_vl_numeric_latest.person_id \n INNER JOIN person ON person.person_id = o.person_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 ) as all_vl_tests_performed \n where VL_Result is not null \n)\n','2021-08-05 18:13:11',4,'2021-08-05 18:13:23',4,0,NULL,NULL,NULL,'008332f3-3206-459e-8bd9-dc2d228427f1'),(1158,'DM_VL_Age','','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n DM_VL_Age\n \n \n 2021-08-05 12:45:06 UTC\n \n 2021-08-05 13:50:13 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n 1158\n \n \n 1-4yrs\n \n \n \n \n maxAge\n 4\n \n \n minAge\n 1\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 15-19yrs\n \n \n \n \n maxAge\n 19\n \n \n minAge\n 15\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 20+\n \n \n \n \n minAge\n 20\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 20-150yrs\n \n \n \n \n maxAge\n 500\n \n \n minAge\n 20\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 5-14yrs\n \n \n \n \n maxAge\n 14\n \n \n minAge\n 5\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n Under 1yr\n \n \n \n \n maxAge\n 1\n \n \n minAge\n 0\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n','2021-08-05 18:15:06',4,'2021-08-05 19:20:13',4,0,NULL,NULL,NULL,'616ff52e-825e-478c-bfd0-280eae62a820'),(1159,'VL_IND-01 Routine VL tests performed','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-01 Routine VL tests performed\n \n \n 2021-08-05 12:50:14 UTC\n \n 2021-08-05 12:51: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 1159\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:20:14',4,'2021-08-05 18:21:12',4,0,NULL,NULL,NULL,'6c42812b-686f-4257-b46b-f24ac4faabfb'),(1160,'VL_IND-06 Targeted detectable VL test results','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-06 Targeted detectable VL test results\n \n \n 2021-08-05 12:51:41 UTC\n \n 2021-08-05 12:52: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 1160\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:21:41',4,'2021-08-05 18:22:10',4,0,NULL,NULL,NULL,'5fb9fa07-e08c-4928-b55e-01ba76096285'),(1161,'VL_IND-08 Pregnant women suppressed VL test results','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-08 Pregnant women suppressed VL test results\n \n \n 2021-08-05 12:52:43 UTC\n \n 2021-08-05 12: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 1161\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:22:43',4,'2021-08-05 18:23:20',4,0,NULL,NULL,NULL,'984eb638-7485-435a-b591-ff3c52051a95'),(1162,'VL_IND-02 Routine suppressed VL tests results','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-02 Routine suppressed VL tests results\n \n \n 2021-08-05 12:53:55 UTC\n \n 2021-08-05 12:54: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 1162\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:23:55',4,'2021-08-05 18:24:50',4,0,NULL,NULL,NULL,'b83be39f-5581-4112-81bd-d98643fa78a4'),(1163,'VL_IND-03 Routine detectable VL tests results','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-03 Routine detectable VL tests results\n \n \n 2021-08-05 12:55:25 UTC\n \n 2021-08-05 12:55: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 1163\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:25:25',4,'2021-08-05 18:25:54',4,0,NULL,NULL,NULL,'a907ba21-f8fe-451e-88bb-5c8a81dbbbc2'),(1164,'VL_IND-04 Targeted VL tests performed','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-04 Targeted VL tests performed\n \n \n 2021-08-05 12:56:41 UTC\n \n 2021-08-05 12:57: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 1164\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:26:41',4,'2021-08-05 18:27:28',4,0,NULL,NULL,NULL,'11ec8256-2f5f-43d9-9438-85d2c0a903de'),(1165,'VL_IND-05 Targeted suppressed VL test results','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-05 Targeted suppressed VL test results\n \n \n 2021-08-05 12:57:57 UTC\n \n 2021-08-09 20: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 1165\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 14:57:57',4,'2021-08-09 22:12:04',4,0,NULL,NULL,NULL,'0addd806-7fef-4d21-82b2-0428e4de1054'),(1166,'VL_IND-07 Pregnant women VL tests performed','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-07 Pregnant women VL tests performed\n \n \n 2021-08-05 12:59:41 UTC\n \n 2021-08-05 13:00: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 1166\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:29:41',4,'2021-08-05 18:30:46',4,0,NULL,NULL,NULL,'922201da-457f-4cd8-b11d-d6ad3d7728a7'),(1167,'VL_IND-09 Pregnant women detectable VL test results','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-09 Pregnant women detectable VL test results\n \n \n 2021-08-05 13:01:24 UTC\n \n 2021-08-05 13:02: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 1167\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:31:24',4,'2021-08-05 18:32:07',4,0,NULL,NULL,NULL,'eaef3f23-91fa-4a4e-bc9f-772d87f36358'),(1168,'VL_IND-10 Breastfeeding mothers VL tests performed','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-10 Breastfeeding mothers VL tests performed\n \n \n 2021-08-05 13:03:18 UTC\n \n 2021-08-05 13:03: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 1168\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:33:18',4,'2021-08-05 18:33:58',4,0,NULL,NULL,NULL,'01a09db0-e7a1-45ea-921b-9ade71ebf924'),(1169,'VL_IND-11 Breastfeeding mothers suppressed VL test results','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-11 Breastfeeding mothers suppressed VL test results\n \n \n 2021-08-05 13:04:56 UTC\n \n 2021-08-05 13:05: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 1169\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:34:56',4,'2021-08-05 18:35:35',4,0,NULL,NULL,NULL,'27ce60dd-678a-41b3-9990-c5844c0d340f'),(1170,'VL_IND-12 Breastfeeding mothers detectable VL test results','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-12 Breastfeeding mothers detectable VL test results\n \n \n 2021-08-05 13:06:10 UTC\n \n 2021-08-05 13:07: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 1170\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:36:10',4,'2021-08-05 18:37:06',4,0,NULL,NULL,NULL,'73d8d389-35a9-413f-baca-72120f9640cb'),(1171,'VL_IND-18 Clients with VL results received in reporting period','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-18 Clients with VL results received in reporting period\n \n \n 2021-08-05 13:07:56 UTC\n \n 2021-08-05 13:08: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 1171\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:37:56',4,'2021-08-05 18:38:36',4,0,NULL,NULL,NULL,'9855b2ec-294e-40be-8b8b-7bda2708019a'),(1172,'VL_IND-20 All VL tests performed','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-20 All VL tests performed\n \n \n 2021-08-05 13:09:38 UTC\n \n 2021-08-05 13:10: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 1172\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:39:38',4,'2021-08-05 18:40:14',4,0,NULL,NULL,NULL,'0c3d2e85-47de-4f40-8213-d9a20d690f1a'),(1173,'VL_IND-21 Suppressed VL tests performed','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-21 Suppressed VL tests performed\n \n \n 2021-08-05 13:11:26 UTC\n \n 2021-08-05 13:12: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 1173\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:41:26',4,'2021-08-05 18:42:12',4,0,NULL,NULL,NULL,'665dfb44-ae19-481f-9caf-51cedb3e9623'),(1174,'VL_IND-22 Detectable VL tests performed','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-22 Detectable VL tests performed\n \n \n 2021-08-05 13:13:35 UTC\n \n 2021-08-05 13:14: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 1174\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-05 18:43:35',4,'2021-08-05 18:44:46',4,0,NULL,NULL,NULL,'b459f37f-41a8-468e-93f9-f3b91ec6baf5'); +INSERT INTO `serialized_object` VALUES (1175,'Viral Load Progress Report','Viral Load Progress Report ->Routine VL tests performed, Targeted VL tests performed, Routine suppressed VL tests results, Routine detectable VL tests results, Breastfeeding mothers VL tests performed, Breastfeeding mothers detectable VL test results, Breastfeeding mothers suppressed VL test results, Pregnant women VL tests performed, Pregnant women detectable VL test results, Pregnant women suppressed VL test results','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Viral Load Progress Report\n Viral Load Progress Report ->Routine VL tests performed, Targeted VL tests performed, Routine suppressed VL tests results, Routine detectable VL tests results, Breastfeeding mothers VL tests performed, Breastfeeding mothers detectable VL test results, Breastfeeding mothers suppressed VL test results, Pregnant women VL tests performed, Pregnant women detectable VL test results, Pregnant women suppressed VL test results\n \n 2021-08-05 13:16:28 UTC\n \n 2021-08-05 13:16: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 1175\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','2021-08-05 18:46:28',4,'2021-08-05 18:46:35',4,0,NULL,NULL,NULL,'7b0e0a97-0012-43e7-8a1b-79d4812c2562'),(1176,'Viral Load Progress 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 Viral Load Progress Report Data Set\n \n 2021-08-05 13:16:35 UTC\n \n 2021-08-09 20:10: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 1176\n \n \n DM_Sex\n \n \n \n \n \n \n DM_VL_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n breas_dete\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 breas_perf\n \n \n \n \n \n \n \n \n \n breas_supp\n \n \n \n \n \n \n \n \n \n preg_detec\n \n \n \n \n \n \n \n \n \n preg_perfr\n \n \n \n \n \n \n \n \n \n preg_suppr\n \n \n \n \n \n \n \n \n \n rout_detec\n \n \n \n \n \n \n \n \n \n rout_suppr\n \n \n \n \n \n \n \n \n \n routin_per\n \n \n \n \n \n \n \n \n \n targ_detec\n \n \n \n \n \n \n \n \n \n targ_perf\n \n \n \n \n \n \n \n \n \n targ_suppr\n \n \n \n \n \n \n \n \n \n','2021-08-05 15:16:35',4,'2021-08-09 22:10:25',4,0,NULL,NULL,NULL,'d93606e1-d4e9-4cff-9377-7a6eb5342a56'),(1177,'Viral Load Progress Report, Age and Sex','','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Viral Load Progress Report, Age and Sex\n \n \n 2021-08-05 13:31:16 UTC\n \n 2021-08-05 13:31: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 1177\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','2021-08-05 19:01:16',4,'2021-08-05 19:01:23',4,0,NULL,NULL,NULL,'0ce6c29e-4969-448c-9607-b4485b2ec729'),(1178,'Viral Load Progress Report, Age and Sex Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Viral Load Progress Report, Age and Sex Data Set\n \n 2021-08-05 13:31:23 UTC\n \n 2021-08-09 20:20: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 1178\n \n \n DM_Sex\n \n \n \n \n \n \n DM_VL_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 1-4yrsF_De\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_VL_Age\n 1-4yrs\n \n \n \n \n \n 1-4yrsF_su\n \n \n \n \n \n \n \n \n \n 1-4yrsF_vl\n \n \n \n \n \n \n \n \n \n 1-4yrsM_De\n \n \n \n \n DM_Sex\n Males\n \n \n DM_VL_Age\n 1-4yrs\n \n \n \n \n \n 1-4yrsM_su\n \n \n \n \n \n \n 1-4yrsM_vl\n \n \n \n \n \n \n 5-14yrsF_D\n \n \n \n \n DM_Sex\n Females\n \n \n DM_VL_Age\n 5-14yrs\n \n \n \n \n \n 5-14yrsF_s\n \n \n \n \n \n \n 5-14yrsF_v\n \n \n \n \n \n \n 5-14yrsM_D\n \n \n \n \n DM_Sex\n Males\n \n \n DM_VL_Age\n 5-14yrs\n \n \n \n \n \n 5-14yrsM_s\n \n \n \n \n \n \n 5-14yrsM_v\n \n \n \n \n \n \n 15-19yF_Su\n \n \n \n \n DM_Sex\n Females\n \n \n DM_VL_Age\n 15-19yrs\n \n \n \n \n \n 15-19yM_Su\n \n \n \n \n DM_Sex\n Males\n \n \n DM_VL_Age\n 15-19yrs\n \n \n \n \n \n 15-19yrF_D\n \n \n \n \n \n \n 15-19yrM_D\n \n \n \n \n \n \n 15-19yrsF\n \n \n \n \n \n \n 15-19yrsM\n \n \n \n \n \n \n 20+yrsF_De\n \n \n \n \n DM_Sex\n Females\n \n \n DM_VL_Age\n 20+\n \n \n \n \n \n 20+yrsF_Su\n \n \n \n \n \n \n 20+yrsF_vl\n \n \n \n \n \n \n 20+yrsM_De\n \n \n \n \n DM_Sex\n Males\n \n \n DM_VL_Age\n 20+\n \n \n \n \n \n 20+yrsM_Su\n \n \n \n \n \n \n 20+yrsM_vl\n \n \n \n \n \n \n <1yrsF_Dec\n \n \n \n \n DM_Sex\n Females\n \n \n DM_VL_Age\n Under 1yr\n \n \n \n \n \n <1yrsF_sup\n \n \n \n \n \n \n <1yrsF_vl\n \n \n \n \n \n \n <1yrsM_Dec\n \n \n \n \n DM_Sex\n Males\n \n \n DM_VL_Age\n Under 1yr\n \n \n \n \n \n <1yrsM_sup\n \n \n \n \n \n \n <1yrsM_vl\n \n \n \n \n \n \n','2021-08-05 15:31:23',4,'2021-08-09 22:20:22',4,0,NULL,NULL,NULL,'e4248881-990d-43ff-ad99-8f95eb362fe9'),(1179,'VL-21 Clients with pending VL test results, within 1 month','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-21 Clients with pending VL test results, within 1 month\n \n \n 2021-08-17 19:08:16 UTC\n \n 2024-02-06 09:10: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 1179\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nwhere o.concept_id = 5494 \n and datediff(cast(o.value_datetime as date), date(date_add(:endDate, interval -1 month))) between 0 and 30 \n and (o.location_id = :location or parent_location = :location) \n and o.voided = 0 \n and o.person_id not in ( \n select distinct os.person_id \n from obs os \n where os.concept_id in (5485,5489) \n and datediff(cast(os.value_datetime as date), date(date_add(:endDate, interval -1 month))) between 0 and 30 \n and o.encounter_id = os.encounter_id \n and os.voided = 0 \n )\n','2021-08-18 00:38:16',4,'2024-02-06 14:40:21',4,0,NULL,NULL,NULL,'3520025c-2f9f-49df-9c87-8a50b0643a54'),(1180,'VL-20 Clients with pending VL test results, within 2 months','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-20 Clients with pending VL test results, within 2 months\n \n \n 2021-08-17 19:12:21 UTC\n \n 2024-02-06 09:12: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 1180\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.concept_id = 5494 \n and datediff(cast(o.value_datetime as date), date(date_add(:endDate, interval -2 month))) between 30 and 60 \n and (o.location_id = :location or parent_location = :location) \n and o.voided = 0 \n and o.person_id not in ( \n select distinct os.person_id \n from obs os \n where os.concept_id in (5485,5489) \n and datediff(cast(os.value_datetime as date), date(date_add(:endDate, interval -2 month))) between 30 and 60 \n and o.encounter_id = os.encounter_id \n and os.voided = 0 \n )\n','2021-08-18 00:42:21',4,'2024-02-06 14:42:40',4,0,NULL,NULL,NULL,'c0967c50-bf72-4423-b3da-97449ab7fa0b'),(1181,'VL-17 Clients with pending VL test results, within 3 months','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-17 Clients with pending VL test results, within 3 months\n \n \n 2021-08-17 19:15:26 UTC\n \n 2024-02-06 09:15: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 1181\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nwhere o.concept_id = 5494 \n and datediff(cast(o.value_datetime as date), date(date_add(:endDate, interval -3 month))) between 60 and 90 \n and (o.location_id = :location or parent_location = :location) \n and o.voided = 0 \n and o.person_id not in ( \n select distinct os.person_id \n from obs os \n where os.concept_id in (5485,5489) \n and datediff(cast(os.value_datetime as date), date(date_add(:endDate, interval -3 month))) between 60 and 90 \n and o.encounter_id = os.encounter_id \n and os.voided = 0 \n )\n','2021-08-18 00:45:26',4,'2024-02-06 14:45:18',4,0,NULL,NULL,NULL,'7d9263e2-ce8a-4d73-a2f5-b521f926d68f'),(1183,'VL-18 Clients with VL results received within 3 months','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-18 Clients with VL results received within 3 months\n \n \n 2021-08-17 19:21:11 UTC\n \n 2024-02-06 09: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 1183\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nwhere o.concept_id = 5494 \n and datediff(cast(o.value_datetime as date), date(date_add(:endDate, interval -3 month))) between 0 and 90 \n and (o.location_id = :location or parent_location = :location) \n and o.voided = 0 \n and o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id in (5485, 5489) \n and datediff(cast(os.value_datetime as date), date(date_add(:endDate, interval -3 month))) between 0 and 90 \n and os.encounter_id = os.encounter_id \n and os.voided = 0 \n )\n','2021-08-18 00:51:11',4,'2024-02-06 14:36:12',4,0,NULL,NULL,NULL,'f0ce5eac-eccc-4e50-95fb-58d508882be7'),(1184,'VL-16 Clients with blood drawn for VL tests in recent 3 months','','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-16 Clients with blood drawn for VL tests in recent 3 months\n \n \n 2021-08-17 19:25:37 UTC\n \n 2024-02-06 08:55: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 1184\n select distinct o.person_id \nfrom obs o \ninner join location l on o.location_id = l.location_id \nwhere o.concept_id = 5494 \n and datediff(o.value_datetime, date(date_add(cast(:endDate as date), interval -3 month))) between 0 and 90 \n and (o.location_id = :location or parent_location = :location) \n and o.voided = 0\n','2021-08-18 00:55:37',4,'2024-02-06 14:25:00',4,0,NULL,NULL,NULL,'086fb891-06bb-43b1-827f-ef9e1a2f1216'),(1185,'VL_IND-13 Clients with pending VL test results, within 1 month','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-13 Clients with pending VL test results, within 1 month\n \n \n 2021-08-17 19:35:14 UTC\n \n 2021-08-17 19: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 1185\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-17 21:35:14',4,'2021-08-17 21:41:15',4,0,NULL,NULL,NULL,'21817a2d-3999-47ec-9e07-44cd74686206'),(1186,'VL_IND-14 Clients with pending VL test results, within 2 months','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-14 Clients with pending VL test results, within 2 months\n \n \n 2021-08-17 19:42:46 UTC\n \n 2021-08-17 19:49: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 1186\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-17 21:42:46',4,'2021-08-17 21:49:46',4,0,NULL,NULL,NULL,'ddec73ad-0c9c-4c53-b7e2-8fedde3c8a2b'),(1187,'VL_IND-15 Clients with pending VL test results, within 3 months','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-15 Clients with pending VL test results, within 3 months\n \n \n 2021-08-17 19:51:42 UTC\n \n 2021-08-17 19:56: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 1187\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-17 21:51:42',4,'2021-08-17 21:56:04',4,0,NULL,NULL,NULL,'5f5b4341-c279-4cd9-96c9-ec727cccc733'),(1188,'VL_IND-16 Clients with blood drawn for VL tests in recent 3 months','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-16 Clients with blood drawn for VL tests in recent 3 months\n \n \n 2021-08-17 19:57:58 UTC\n \n 2021-08-17 19:59: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 1188\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-17 21:57:58',4,'2021-08-17 21:59:21',4,0,NULL,NULL,NULL,'81898c9b-878a-4cf5-ad51-c3190878f2c3'),(1189,'VL_IND-17 Clients with VL results received within 3 months','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL_IND-17 Clients with VL results received within 3 months\n \n \n 2021-08-17 20:00:16 UTC\n \n 2021-08-17 20: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 1189\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-08-17 22:00:16',4,'2021-08-17 22:00:58',4,0,NULL,NULL,NULL,'981a63bf-3e3d-49b6-9ff9-251508dc6d5e'),(1191,'Weekly Viral Load Report','','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Weekly Viral Load Report\n \n \n 2021-08-17 20:12:39 UTC\n \n 2021-08-17 20:12: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 1191\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','2021-08-17 22:12:39',4,'2021-08-17 22:12:46',4,0,NULL,NULL,NULL,'eab176b2-ffbc-43b1-8d96-1fc703df2009'),(1192,'Weekly Viral Load 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 Weekly Viral Load Report Data Set\n \n 2021-08-17 20:12:46 UTC\n \n 2021-08-17 20: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 1192\n \n \n \n VL_BD_3M\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 VL_Res_3M\n \n \n \n \n \n \n \n \n \n VL_Res_CM\n \n \n \n \n \n \n \n \n \n VL_Rs_P_1M\n \n \n \n \n \n \n \n \n \n VL_Rs_P_2M\n \n \n \n \n \n \n \n \n \n VL_Rs_P_3M\n \n \n \n \n \n \n \n \n \n','2021-08-17 22:12:46',4,'2021-08-17 22:27:22',4,0,NULL,NULL,NULL,'637a51c0-da3c-4ce0-a904-8c1b6d02f7ee'),(1193,'PIR-17 Tx_CURR Retention Report','','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR-17 Tx_CURR Retention Report\n \n \n 2021-09-17 02:00:37 UTC\n \n 2021-09-17 02:00: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 1193\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','2021-09-17 04:00:37',4,'2021-09-17 04:00:45',4,0,NULL,NULL,NULL,'7acdbe71-cb34-40fc-839e-ff902abd9aaa'),(1194,'PIR-17 Tx_CURR Retention 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 PIR-17 Tx_CURR Retention Report Data Set\n \n 2021-09-17 02:00:45 UTC\n \n 2022-08-24 09:26: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 1194\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n MMDF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n MMDF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n MMDF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n MMDF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n MMDF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n MMDF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n MMDF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n MMDF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n MMDF45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n MMDF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n MMDF50\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n MMDF<1yr\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n MMDM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n MMDM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n MMDM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n MMDM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n MMDM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n MMDM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n MMDM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n MMDM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n MMDM45-49\n \n \n \n \n \n \n MMDM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n MMDM50\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n MMDM<1yr\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n R_IIT<3F1-\n \n \n \n \n \n \n \n \n \n R_IIT<3F10\n \n \n \n \n \n \n R_IIT<3F15\n \n \n \n \n \n \n R_IIT<3F20\n \n \n \n \n \n \n R_IIT<3F25\n \n \n \n \n \n \n R_IIT<3F30\n \n \n \n \n \n \n R_IIT<3F35\n \n \n \n \n \n \n R_IIT<3F40\n \n \n \n \n \n \n R_IIT<3F45\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n R_IIT<3F5-\n \n \n \n \n \n \n R_IIT<3F50\n \n \n \n \n \n \n R_IIT<3F<1\n \n \n \n \n \n \n R_IIT<3M1-\n \n \n \n \n \n \n R_IIT<3M10\n \n \n \n \n \n \n R_IIT<3M15\n \n \n \n \n \n \n R_IIT<3M20\n \n \n \n \n \n \n R_IIT<3M25\n \n \n \n \n \n \n R_IIT<3M30\n \n \n \n \n \n \n R_IIT<3M35\n \n \n \n \n \n \n R_IIT<3M40\n \n \n \n \n \n \n R_IIT<3M45\n \n \n \n \n \n \n R_IIT<3M5-\n \n \n \n \n \n \n R_IIT<3M50\n \n \n \n \n \n \n R_IIT<3M<1\n \n \n \n \n \n \n RIIT3-5F1-\n \n \n \n \n \n \n \n \n \n RIIT3-5F10\n \n \n \n \n \n \n RIIT3-5F15\n \n \n \n \n \n \n RIIT3-5F20\n \n \n \n \n \n \n RIIT3-5F25\n \n \n \n \n \n \n RIIT3-5F30\n \n \n \n \n \n \n RIIT3-5F35\n \n \n \n \n \n \n RIIT3-5F40\n \n \n \n \n \n \n RIIT3-5F45\n \n \n \n \n \n \n RIIT3-5F5-\n \n \n \n \n \n \n RIIT3-5F50\n \n \n \n \n \n \n RIIT3-5F<1\n \n \n \n \n \n \n RIIT3-5M1-\n \n \n \n \n \n \n RIIT3-5M10\n \n \n \n \n \n \n RIIT3-5M15\n \n \n \n \n \n \n RIIT3-5M20\n \n \n \n \n \n \n RIIT3-5M25\n \n \n \n \n \n \n RIIT3-5M30\n \n \n \n \n \n \n RIIT3-5M35\n \n \n \n \n \n \n RIIT3-5M40\n \n \n \n \n \n \n RIIT3-5M45\n \n \n \n \n \n \n RIIT3-5M5-\n \n \n \n \n \n \n RIIT3-5M50\n \n \n \n \n \n \n RIIT3-5M<1\n \n \n \n \n \n \n RIIT6pF1-4\n \n \n \n \n \n \n \n \n \n RIIT6pF10-\n \n \n \n \n \n \n RIIT6pF15-\n \n \n \n \n \n \n RIIT6pF20-\n \n \n \n \n \n \n RIIT6pF25-\n \n \n \n \n \n \n RIIT6pF30-\n \n \n \n \n \n \n RIIT6pF35-\n \n \n \n \n \n \n RIIT6pF40-\n \n \n \n \n \n \n RIIT6pF45-\n \n \n \n \n \n \n RIIT6pF5-9\n \n \n \n \n \n \n RIIT6pF50-\n \n \n \n \n \n \n RIIT6pF<1\n \n \n \n \n \n \n RIIT6pM1-4\n \n \n \n \n \n \n RIIT6pM10-\n \n \n \n \n \n \n RIIT6pM15-\n \n \n \n \n \n \n RIIT6pM20-\n \n \n \n \n \n \n RIIT6pM25-\n \n \n \n \n \n \n RIIT6pM30-\n \n \n \n \n \n \n RIIT6pM35-\n \n \n \n \n \n \n RIIT6pM40-\n \n \n \n \n \n \n RIIT6pM45-\n \n \n \n \n \n \n RIIT6pM5-9\n \n \n \n \n \n \n RIIT6pM50-\n \n \n \n \n \n \n RIIT6pM<1\n \n \n \n \n \n \n SeenF1-4\n \n \n \n \n \n \n \n \n \n SeenF10-14\n \n \n \n \n \n \n SeenF15-19\n \n \n \n \n \n \n SeenF20-24\n \n \n \n \n \n \n SeenF25-29\n \n \n \n \n \n \n SeenF30-34\n \n \n \n \n \n \n SeenF35-39\n \n \n \n \n \n \n SeenF40-44\n \n \n \n \n \n \n SeenF45-49\n \n \n \n \n \n \n SeenF5-9\n \n \n \n \n \n \n SeenF50\n \n \n \n \n \n \n SeenF<1yr\n \n \n \n \n \n \n SeenM1-4\n \n \n \n \n \n \n SeenM10-14\n \n \n \n \n \n \n SeenM15-19\n \n \n \n \n \n \n SeenM20-24\n \n \n \n \n \n \n SeenM25-29\n \n \n \n \n \n \n SeenM30-34\n \n \n \n \n \n \n SeenM35-39\n \n \n \n \n \n \n SeenM40-44\n \n \n \n \n \n \n SeenM45-49\n \n \n \n \n \n \n SeenM5-9\n \n \n \n \n \n \n SeenM50\n \n \n \n \n \n \n SeenM<1yr\n \n \n \n \n \n \n T/InF1-4\n \n \n \n \n \n \n \n \n \n T/InF10-14\n \n \n \n \n \n \n T/InF15-19\n \n \n \n \n \n \n T/InF20-24\n \n \n \n \n \n \n T/InF25-29\n \n \n \n \n \n \n T/InF30-34\n \n \n \n \n \n \n T/InF35-39\n \n \n \n \n \n \n T/InF40-44\n \n \n \n \n \n \n T/InF45-49\n \n \n \n \n \n \n T/InF5-9\n \n \n \n \n \n \n T/InF50\n \n \n \n \n \n \n T/InF<1yr\n \n \n \n \n \n \n T/InM1-4\n \n \n \n \n \n \n T/InM10-14\n \n \n \n \n \n \n T/InM15-19\n \n \n \n \n \n \n T/InM20-24\n \n \n \n \n \n \n T/InM25-29\n \n \n \n \n \n \n T/InM30-34\n \n \n \n \n \n \n T/InM35-39\n \n \n \n \n \n \n T/InM40-44\n \n \n \n \n \n \n T/InM45-49\n \n \n \n \n \n \n T/InM5-9\n \n \n \n \n \n \n T/InM50\n \n \n \n \n \n \n T/InM<1yr\n \n \n \n \n \n \n','2021-09-17 02:00:45',4,'2022-08-24 09:26:32',4,0,NULL,NULL,NULL,'44c35489-bda8-422a-abd6-239ec4495167'),(1195,'TX_ML-01 Clients who are current on ART at reporting period and experienced IIT_Died','TX_ML-01 Clients who are current on ART at reporting period and experienced IIT_Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_ML-01 Clients who are current on ART at reporting period and experienced IIT_Died\n TX_ML-01 Clients who are current on ART at reporting period and experienced IIT_Died\n \n 2021-09-17 02:02:13 UTC\n \n 2024-02-15 08: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 endDateas\n \n java.util.Date\n true\n \n \n 1195\n select obs_ml_clients.person_id \nfrom obs os \ninner join location l on os.location_id = l.location_id \ninner join \n( \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) < 29) as On_ART_Beginning_Quarter \n ) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n UNION \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 2249 and cast(o.value_datetime as date) >= cast(:startDate as DATE) and cast(o.value_datetime as date) <= cast(:endDate as DATE) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n) as obs_ml_clients on os.person_id = obs_ml_clients.person_id \nINNER JOIN person ON person.person_id = obs_ml_clients.person_id AND person.voided = 0 \nINNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \nWHERE os.location_id =:location or parent_location =:location \n AND obs_ml_clients.person_id in ( \n select person_id \n from person \n where death_date <= CAST(:endDate AS DATE) \n and dead = 1 \n ) \nAND obs_ml_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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n )\n','2021-09-17 07:32:13',4,'2024-02-15 14:06:30',4,0,NULL,NULL,NULL,'8d2c7d4f-adbf-4aa0-bd9e-e19ce887a64f'),(1196,'TX_ML-02 Clients who are current on ART at reporting period and experienced IIT<3months','TX_ML-02 Clients who are current on ART at reporting period and experienced IIT<3months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_ML-02 Clients who are current on ART at reporting period and experienced IIT<3months\n TX_ML-02 Clients who are current on ART at reporting period and experienced IIT<3months\n \n 2021-09-17 02:02:54 UTC\n \n 2024-02-15 08:37: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 1196\n select obs_ml_clients.person_id \nfrom obs os \ninner join location l on os.location_id = l.location_id \ninner join \n( \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) < 29) as On_ART_Beginning_Quarter \n ) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n UNION \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 2249 and cast(o.value_datetime as date) >= cast(:startDate as DATE) and cast(o.value_datetime as date) <= cast(:endDate as DATE) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n) as obs_ml_clients on os.person_id = obs_ml_clients.person_id \nINNER JOIN person ON person.person_id = obs_ml_clients.person_id AND person.voided = 0 \nINNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \nWHERE os.location_id =:location or parent_location =:location \n -- INITIATED ON ART LESS THAN 3 MONTHS AGO \n AND obs_ml_clients.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 2249 \n AND datediff(CAST(:endDate AS DATE), os.value_datetime) BETWEEN 0 AND 90 \n ) \n -- NOT Transfered Out to Another Site \n AND obs_ml_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 4155 and os.value_coded = 2146 \n AND os.obs_datetime <= CAST(:endDate AS DATE) \n ) \n -- NOT DEAD \n AND obs_ml_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 ) \nAND obs_ml_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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n )\n','2021-09-17 07:32:54',4,'2024-02-15 14:07:28',4,0,NULL,NULL,NULL,'ed95842b-5f50-4afe-89c1-b1761191123e'),(1197,'TX_ML-03 Clients who are current on ART at reporting period and experienced IIT_6+months','TX_ML-03 Clients who are current on ART at reporting period and experienced IIT_6+months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_ML-03 Clients who are current on ART at reporting period and experienced IIT_6+months\n TX_ML-03 Clients who are current on ART at reporting period and experienced IIT_6+months\n \n 2021-09-17 02:04:20 UTC\n \n 2024-02-15 08:44: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 1197\n select obs_ml_clients.person_id \nfrom obs os \ninner join location l on os.location_id = l.location_id \ninner join \n( \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) < 29) as On_ART_Beginning_Quarter \n ) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n UNION \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 2249 and cast(o.value_datetime as date) >= cast(:startDate as DATE) and cast(o.value_datetime as date) <= cast(:endDate as DATE) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n) as obs_ml_clients on os.person_id = obs_ml_clients.person_id \nINNER JOIN person ON person.person_id = obs_ml_clients.person_id AND person.voided = 0 \nINNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \nWHERE os.location_id =:location or parent_location =:location \n -- INITIATED ON ART MORE THAN 3 MONTHS AGO \n AND obs_ml_clients.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 2249 \n AND datediff(CAST(:endDate AS DATE), os.value_datetime) >= 180 \n ) \n -- NOT Transfered Out to Another Site \n AND obs_ml_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 4155 and os.value_coded = 2146 \n AND os.obs_datetime <= CAST(:endDate AS DATE) \n ) \n -- NOT DEAD \n AND obs_ml_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 ) \nAND obs_ml_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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n )\n','2021-09-17 07:34:20',4,'2024-02-15 14:14:36',4,0,NULL,NULL,NULL,'11fdf33c-0d64-4c86-8ece-f8eb55ed6119'),(1198,'TX_ML-04 Clients who are current on ART at reporting period and experienced IIT_TOut','TX_ML-04 Clients who are current on ART at reporting period and experienced IIT_TOut','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_ML-04 Clients who are current on ART at reporting period and experienced IIT_TOut\n TX_ML-04 Clients who are current on ART at reporting period and experienced IIT_TOut\n \n 2021-09-17 02:05:17 UTC\n \n 2024-02-15 09:01: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 endDateas\n \n java.util.Date\n true\n \n \n 1198\n select obs_ml_clients.person_id \nfrom obs os \ninner join location l on os.location_id = l.location_id \ninner join \n( \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) < 1) as On_ART_Beginning_Quarter \n ) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 0) as Missed_Greater_Than_0Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n UNION \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 2249 and cast(o.value_datetime as date) >= cast(:startDate as DATE) and cast(o.value_datetime as date) <= cast(:endDate as DATE) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 0) as Missed_Greater_Than_0Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n) as obs_ml_clients on os.person_id = obs_ml_clients.person_id \nINNER JOIN person ON person.person_id = obs_ml_clients.person_id AND person.voided = 0 \nINNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \nWHERE os.location_id =:location or parent_location =:location \n -- Transfered Out to Another Site \n AND obs_ml_clients.person_id in ( \n \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 -- NOT DEAD \n AND obs_ml_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 AND obs_ml_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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n )\n','2021-09-17 07:35:17',4,'2024-02-15 14:31:14',4,0,NULL,NULL,NULL,'d19bded0-5e8e-4aeb-a41f-f5c6921d90a9'),(1199,'TX_ML-05 Clients who are current on ART at reporting period and experienced IIT_Stopped','TX_ML-05 Clients who are current on ART at reporting period and experienced IIT_Stopped','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_ML-05 Clients who are current on ART at reporting period and experienced IIT_Stopped\n TX_ML-05 Clients who are current on ART at reporting period and experienced IIT_Stopped\n \n 2021-09-17 02:06:20 UTC\n \n 2024-02-15 09:02: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 1199\n select obs_ml_clients.person_id \nfrom obs os \ninner join location l on os.location_id = l.location_id \ninner join \n( \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) < 29) as On_ART_Beginning_Quarter \n ) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n UNION \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 2249 and cast(o.value_datetime as date) >= cast(:startDate as DATE) and cast(o.value_datetime as date) <= cast(:endDate as DATE) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n) as obs_ml_clients on os.person_id = obs_ml_clients.person_id \nINNER JOIN person ON person.person_id = obs_ml_clients.person_id AND person.voided = 0 \nINNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \nWHERE os.location_id =:location or parent_location =:location \n -- ART TREATMENT INTERRUPTION/REFUSED OR STOPPED \n AND obs_ml_clients.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 3701 \n AND os.value_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \nAND obs_ml_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 ) \nAND obs_ml_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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n )\n','2021-09-17 07:36:20',4,'2024-02-15 14:32:17',4,0,NULL,NULL,NULL,'436959a2-8534-4a1e-9e76-3baf516b8620'),(1200,'TX_RTT-01 Clients with IIT in previous period who restarted ARV\'s during current period','TX_RTT-01 Clients with IIT in previous period who restarted ARV\'s during current period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_RTT-01 Clients with IIT in previous period who restarted ARV's during current period\n TX_RTT-01 Clients with IIT in previous period who restarted ARV's during current period\n \n 2021-09-17 02:07:07 UTC\n \n 2021-09-17 02:07: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 1200\n select distinct o.person_id \nfrom obs o \n-- PATIENTS WITH NO CLINICAL CONTACT OR ARV PICK-UP FOR GREATER THAN 28 DAYS \n-- SINCE THEIR LAST EXPECTED CONTACT WHO RESTARTED ARVs WITHIN THE REPORTING PERIOD \ninner join location l on o.location_id = l.location_id \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND patient.voided = 0 AND o.voided = 0 \nAND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n \n -- Client Seen: As either patient OR Treatment Buddy \n AND ( \n o.person_id 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 os.obs_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n \n -- Client Seen and Date Restarted picked \n OR o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 3708 AND os.value_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n ) \n -- Still on treatment at the end of the reporting period \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime >= cast(:startDate as DATE) and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) <= 28) as Still_On_Treatment_End_Period \n ) \n \n -- Transfered Out to Another Site during thier latest encounter before the start date \n AND o.person_id not in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS last_obs_tout \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 4155 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having last_obs_tout = 2146) as Transfered_Out_In_Last_Encounter \n ) \n \n-- NOT Transfered In from another Site \n AND o.person_id not in ( \n select os.person_id \n from obs os \n where (os.concept_id = 2253 AND DATE(os.value_datetime) BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE)) \n AND os.voided = 0 \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 \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 \nWHERE (o.location_id =:location or parent_location =:location)\n','2021-09-17 04:07:07',4,'2021-09-17 04:07:22',4,0,NULL,NULL,NULL,'2ada18e8-c557-4e96-ac65-84648ec56b7f'),(1201,'Continuation ART Clients Seen ','Continuation ART Clients Seen excl Transfers In, TxRTT','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Continuation ART Clients Seen \n Continuation ART Clients Seen excl Transfers In, TxRTT\n \n 2021-09-17 02:08:18 UTC\n \n 2021-09-17 02:09: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 1201\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 \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 CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH) \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 NEWLY 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(:startDate AS DATE)) \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 ) \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(:startDate AS DATE) \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 -3 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 \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(:startDate AS DATE) \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 -3 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 ) \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 ) \n ) \n \n-- Exclude Transfers In \nAND Clients_Seen.Id not in ( \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON patient.patient_id = person.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 where concept_id = 3634 and o.value_coded = 2095 \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 CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH) \n and o.voided = 0) \n \n \nAND Clients_Seen.Id not in ( \n \nselect distinct (o.person_id) \nfrom obs o \n-- PATIENTS WITH NO CLINICAL CONTACT OR ARV PICK-UP FOR GREATER THAN 28 DAYS \n-- SINCE THEIR LAST EXPECTED CONTACT WHO RESTARTED ARVs WITHIN THE REPORTING PERIOD \n-- inner join location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON patient.patient_id = person.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 patient.voided = 0 AND o.voided = 0 \nwhere o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n \n AND ( \n o.person_id 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 os.obs_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n \n -- Client Seen and Date Restarted picked \n OR o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 3708 AND os.value_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n ) \n \n -- Still on treatment at the end of the reporting period \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime >= cast(:startDate as DATE) and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) <= 28) as Still_On_Treatment_End_Period \n ) \n \n -- Transfered Out to Another Site during thier latest encounter before the start date \n AND o.person_id not in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS last_obs_tout \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 4155 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having last_obs_tout = 2146) as Transfered_Out_In_Last_Encounter \n ) \n \n-- NOT Transfered In from another Site \n AND o.person_id not in ( \n select os.person_id \n from obs os \n where (os.concept_id = 2253 AND DATE(os.value_datetime) BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE)) \n AND os.voided = 0 \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 \n ) \n \n))\n','2021-09-17 04:08:18',4,'2021-09-17 04:09:23',4,0,NULL,NULL,NULL,'6d452652-2e45-4009-a6fc-a00231e470ce'),(1202,'Continuation ART Clients On MMD','Continuation ART Clients On MMD excl Seen, Transfers In, TxRTT','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Continuation ART Clients On MMD\n Continuation ART Clients On MMD excl Seen, Transfers In, TxRTT\n \n 2021-09-17 02:10:59 UTC\n \n 2021-09-17 02:11: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 1202\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 \n(SELECT Id \nFROM ( \n \n (SELECT Id, patientIdentifier , patientName, Age, Gender, age_group, 'Seen_Previous' AS 'Program_Status', sort_order \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.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 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 \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 CAST(os.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND CAST(os.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH) \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(:startDate AS DATE)) \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(:startDate AS DATE) \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 -3 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 and active_clients.person_id not in ( \n -- Transfers In \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON patient.patient_id = person.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 where concept_id = 3634 and o.value_coded = 2095 \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 CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH) \n and o.voided = 0 \n \n \n ) \n \n and active_clients.person_id not in ( \n \n select distinct (o.person_id) \n from obs o \n -- PATIENTS WITH NO CLINICAL CONTACT OR ARV PICK-UP FOR GREATER THAN 28 DAYS \n -- SINCE THEIR LAST EXPECTED CONTACT WHO RESTARTED ARVs WITHIN THE REPORTING PERIOD \n -- inner join location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON patient.patient_id = person.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 patient.voided = 0 AND o.voided = 0 \n where o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n \n AND ( \n o.person_id 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 os.obs_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n \n -- Client Seen and Date Restarted picked \n OR o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 3708 AND os.value_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n ) \n \n -- Still on treatment at the end of the reporting period \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime >= cast(:startDate as DATE) and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) <= 28) as Still_On_Treatment_End_Period \n ) \n \n -- Transfered Out to Another Site during thier latest encounter before the start date \n AND o.person_id not in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS last_obs_tout \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 4155 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having last_obs_tout = 2146) as Transfered_Out_In_Last_Encounter \n ) \n \n -- NOT Transfered In from another Site \n AND o.person_id not in ( \n select os.person_id \n from obs os \n where (os.concept_id = 2253 AND DATE(os.value_datetime) BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE)) \n AND os.voided = 0 \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 \n ) \n \n ) \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)AS Seen_Prev)\n','2021-09-17 04:10:59',4,'2021-09-17 04:11:17',4,0,NULL,NULL,NULL,'6c3b70a0-3830-4598-aba2-92ac32c4d52d'),(1203,'Continuation ART Clients Transferred In','Continuation ART Clients Transferred In','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Continuation ART Clients Transferred In\n Continuation ART Clients Transferred In\n \n 2021-09-17 02:12:22 UTC\n \n 2021-09-17 02:12: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 1203\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 \n(select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON patient.patient_id = person.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 where concept_id = 3634 and o.value_coded = 2095 \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 CAST(o.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH) \n and o.voided = 0)\n','2021-09-17 04:12:22',4,'2021-09-17 04:12:38',4,0,NULL,NULL,NULL,'47d0abca-f9d5-48b3-9151-647a732e9a76'),(1204,'CI46: TxML Died','TxML Died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI46: TxML Died\n TxML Died\n \n 2021-09-17 02:14:41 UTC\n \n 2021-09-17 06:22: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 1204\n COUNT\n \n \n \n \n endDate\n ${}\n \n \n location\n ${}\n \n \n startDate\n ${}\n \n \n \n','2021-09-17 04:14:41',4,'2021-09-17 08:22:13',4,0,NULL,NULL,NULL,'8952b48b-2d4e-4f46-8996-b6fc498327f5'),(1205,'CI47: TxML IIT<3months','TxML IIT<3months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI47: TxML IIT<3months\n TxML IIT<3months\n \n 2021-09-17 02:16:05 UTC\n \n 2021-09-17 02:18: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 1205\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-17 04:16:05',4,'2021-09-17 04:18:12',4,0,NULL,NULL,NULL,'4b660dac-a834-406b-b06e-90944ea1eec0'),(1206,'CI48:TxML IIT_6+','TxML IIT3_6+','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI48:TxML IIT_6+\n TxML IIT3_6+\n \n 2021-09-17 02:18:56 UTC\n \n 2022-08-10 11:05: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 1206\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-17 02:18:56',4,'2022-08-10 11:05:52',4,0,NULL,NULL,NULL,'c8cca19d-b858-4d1f-8ba4-855aa09d937e'),(1207,'CI50:TxML Stopped','TxML Stopped','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI50:TxML Stopped\n TxML Stopped\n \n 2021-09-17 02:19:58 UTC\n \n 2021-09-17 02:20: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 1207\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-17 04:19:58',4,'2021-09-17 04:20:32',4,0,NULL,NULL,NULL,'d09049bb-71b1-49c2-8e3b-d99b6216278f'),(1208,'CI49:TxML Transferred Out','TxML Transferred Out','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI49:TxML Transferred Out\n TxML Transferred Out\n \n 2021-09-17 02:21:09 UTC\n \n 2021-09-17 02:21: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 1208\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-17 04:21:09',4,'2021-09-17 04:21:47',4,0,NULL,NULL,NULL,'3858c3a8-5614-4f42-b8d5-caba30f4013d'),(1209,'CI45:TxRTT','CI45:TxRTT','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI45:TxRTT\n CI45:TxRTT\n \n 2021-09-17 02:22:14 UTC\n \n 2021-09-17 02:22: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 1209\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-17 04:22:14',4,'2021-09-17 04:22:55',4,0,NULL,NULL,NULL,'c80e8686-73e9-4cd4-ad59-eab7f5045773'),(1210,'CI51:Continuation ART Clients Seen','Continuation ART Clients Seen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI51:Continuation ART Clients Seen\n Continuation ART Clients Seen\n \n 2021-09-17 02:23:46 UTC\n \n 2021-09-17 02:24: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 1210\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-17 04:23:46',4,'2021-09-17 04:24:25',4,0,NULL,NULL,NULL,'ca465d0c-322d-4d62-820d-979df9b462bc'),(1211,'CI52:Continuation ART Clients On MMD','Continuation ART Clients On MMD','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI52:Continuation ART Clients On MMD\n Continuation ART Clients On MMD\n \n 2021-09-17 02:25:01 UTC\n \n 2021-09-17 02:25: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 1211\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-17 04:25:01',4,'2021-09-17 04:25:47',4,0,NULL,NULL,NULL,'37780447-34b7-46ab-8f48-5701f6107663'),(1212,'CI53:Continuation ART Clients Transferred In','Continuation ART Clients Transferred In','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI53:Continuation ART Clients Transferred In\n Continuation ART Clients Transferred In\n \n 2021-09-17 02:27:04 UTC\n \n 2021-09-17 02:31: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 1212\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-17 04:27:04',4,'2021-09-17 04:31:06',4,0,NULL,NULL,NULL,'04fe1c76-7f90-4ac2-9c23-00651194ebaf'),(1213,'PIR-17 Tx_CURR Retention Report2','Tx_CURR Retention Report2 Aggregated','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR-17 Tx_CURR Retention Report2\n Tx_CURR Retention Report2 Aggregated\n \n 2021-09-17 05:41:13 UTC\n \n 2021-09-17 05: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 1213\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','2021-09-17 07:41:13',4,'2021-09-17 07:41:37',4,0,NULL,NULL,NULL,'0e82afa4-1875-4274-bba1-3cc7b7ba33e2'),(1214,'PIR-17 Tx_CURR Retention Report2 Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR-17 Tx_CURR Retention Report2 Data Set\n \n 2021-09-17 05:41:37 UTC\n \n 2021-09-17 06:02: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 1214\n \n \n \n TxML Died\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 Cont-MMD\n \n \n \n \n \n \n \n \n \n Cont-Seen\n \n \n \n \n \n \n \n \n \n Cont-T/In\n \n \n \n \n \n \n \n \n \n TxML IIT<3\n \n \n \n \n \n \n \n \n \n TxML IIT>3\n \n \n \n \n \n \n \n \n \n TxML Stopp\n \n \n \n \n \n \n \n \n \n TxML T/Out\n \n \n \n \n \n \n \n \n \n TxRTT\n \n \n \n \n \n \n \n \n \n','2021-09-17 07:41:37',4,'2021-09-17 08:02:25',4,0,NULL,NULL,NULL,'046b6e02-8095-4280-bd2d-a729548a2a0a'),(1215,'PIR-17 Tx_CURR TXML','TXML Report including Died,IIT<3months, IIT3-5months,IIT6+months,Transferred Out, Stopped','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR-17 Tx_CURR TXML\n TXML Report including Died,IIT<3months, IIT3-5months,IIT6+months,Transferred Out, Stopped\n \n 2021-09-21 10:52:46 UTC\n \n 2022-08-30 09:40: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 1215\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','2021-09-21 10:52:46',4,'2022-08-30 09:40:54',4,0,NULL,NULL,NULL,'a8849fa6-fe2a-4273-bd0b-c284635ed6c2'),(1216,'PIR-17 Tx_CURR TXML Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PIR-17 Tx_CURR TXML Data Set\n \n 2021-09-21 10:52:57 UTC\n \n 2022-09-23 08:18: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 1216\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n DiedF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n DiedF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n DiedF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n DiedF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n DiedF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n DiedF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n DiedF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n DiedF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n DiedF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n DiedF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n DiedF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n DiedF<1yr\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n DiedM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n DiedM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n DiedM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n DiedM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n DiedM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n DiedM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n DiedM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n DiedM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n DiedM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n DiedM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n DiedM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n DiedM<1yr\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n IIT3-5F1-4\n \n \n \n \n \n \n \n \n \n IIT3-5F10-\n \n \n \n \n \n \n IIT3-5F15-\n \n \n \n \n \n \n IIT3-5F20-\n \n \n \n \n \n \n IIT3-5F25-\n \n \n \n \n \n \n IIT3-5F30-\n \n \n \n \n \n \n IIT3-5F35-\n \n \n \n \n \n \n IIT3-5F40-\n \n \n \n \n \n \n IIT3-5F45-\n \n \n \n \n \n \n IIT3-5F5-9\n \n \n \n \n \n \n IIT3-5F50-\n \n \n \n \n \n \n IIT3-5F<1\n \n \n \n \n \n \n IIT3-5M1-4\n \n \n \n \n \n \n IIT3-5M10-\n \n \n \n \n \n \n IIT3-5M15-\n \n \n \n \n \n \n IIT3-5M20-\n \n \n \n \n \n \n IIT3-5M25-\n \n \n \n \n \n \n IIT3-5M30-\n \n \n \n \n \n \n IIT3-5M35-\n \n \n \n \n \n \n IIT3-5M40-\n \n \n \n \n \n \n IIT3-5M45-\n \n \n \n \n \n \n IIT3-5M5-9\n \n \n \n \n \n \n IIT3-5M50p\n \n \n \n \n \n \n IIT3-5M<1\n \n \n \n \n \n \n IIT6pF1-4\n \n \n \n \n \n \n \n \n \n IIT6pF10-1\n \n \n \n \n \n \n IIT6pF15-1\n \n \n \n \n \n \n IIT6pF20-2\n \n \n \n \n \n \n IIT6pF25-2\n \n \n \n \n \n \n IIT6pF30-3\n \n \n \n \n \n \n IIT6pF35-3\n \n \n \n \n \n \n IIT6pF40-4\n \n \n \n \n \n \n IIT6pF45-4\n \n \n \n \n \n \n IIT6pF5-9\n \n \n \n \n \n \n IIT6pF50Pl\n \n \n \n \n \n \n IIT6pF<1yr\n \n \n \n \n \n \n IIT6pM1-4\n \n \n \n \n \n \n IIT6pM10-1\n \n \n \n \n \n \n IIT6pM15-1\n \n \n \n \n \n \n IIT6pM20-2\n \n \n \n \n \n \n IIT6pM25-2\n \n \n \n \n \n \n IIT6pM30-3\n \n \n \n \n \n \n IIT6pM35-3\n \n \n \n \n \n \n IIT6pM40-4\n \n \n \n \n \n \n IIT6pM45-4\n \n \n \n \n \n \n IIT6pM5-9\n \n \n \n \n \n \n IIT6pM50Pl\n \n \n \n \n \n \n IIT6pM<1yr\n \n \n \n \n \n \n IIT<3F1-4\n \n \n \n \n \n \n \n \n \n IIT<3F10-1\n \n \n \n \n \n \n IIT<3F15-1\n \n \n \n \n \n \n IIT<3F20-2\n \n \n \n \n \n \n IIT<3F25-2\n \n \n \n \n \n \n IIT<3F30-3\n \n \n \n \n \n \n IIT<3F35-3\n \n \n \n \n \n \n IIT<3F40-4\n \n \n \n \n \n \n IIT<3F45-4\n \n \n \n \n \n \n IIT<3F5-9\n \n \n \n \n \n \n IIT<3F50Pl\n \n \n \n \n \n \n IIT<3F<1yr\n \n \n \n \n \n \n IIT<3M1-4\n \n \n \n \n \n \n IIT<3M10-1\n \n \n \n \n \n \n IIT<3M15-1\n \n \n \n \n \n \n IIT<3M20-2\n \n \n \n \n \n \n IIT<3M25-2\n \n \n \n \n \n \n IIT<3M30-3\n \n \n \n \n \n \n IIT<3M35-3\n \n \n \n \n \n \n IIT<3M40-4\n \n \n \n \n \n \n IIT<3M45-4\n \n \n \n \n \n \n IIT<3M5-9\n \n \n \n \n \n \n IIT<3M50Pl\n \n \n \n \n \n \n IIT<3M<1yr\n \n \n \n \n \n \n StopF1-4\n \n \n \n \n \n \n \n \n \n StopF10-14\n \n \n \n \n \n \n StopF15-19\n \n \n \n \n \n \n StopF20-24\n \n \n \n \n \n \n StopF25-29\n \n \n \n \n \n \n StopF30-34\n \n \n \n \n \n \n StopF35-39\n \n \n \n \n \n \n StopF40-44\n \n \n \n \n \n \n StopF45-49\n \n \n \n \n \n \n StopF5-9\n \n \n \n \n \n \n StopF50Plu\n \n \n \n \n \n \n StopF<1yr\n \n \n \n \n \n \n StopM1-4\n \n \n \n \n \n \n StopM10-14\n \n \n \n \n \n \n StopM15-19\n \n \n \n \n \n \n StopM20-24\n \n \n \n \n \n \n StopM25-29\n \n \n \n \n \n \n StopM30-34\n \n \n \n \n \n \n StopM35-39\n \n \n \n \n \n \n StopM40-44\n \n \n \n \n \n \n StopM45-49\n \n \n \n \n \n \n StopM5-9\n \n \n \n \n \n \n StopM50Plu\n \n \n \n \n \n \n StopM<1yr\n \n \n \n \n \n \n TOutF1-4\n \n \n \n \n \n \n \n \n \n TOutF10-14\n \n \n \n \n \n \n TOutF15-19\n \n \n \n \n \n \n TOutF20-24\n \n \n \n \n \n \n TOutF25-29\n \n \n \n \n \n \n TOutF30-34\n \n \n \n \n \n \n TOutF35-39\n \n \n \n \n \n \n TOutF40-44\n \n \n \n \n \n \n TOutF45-49\n \n \n \n \n \n \n TOutF5-9\n \n \n \n \n \n \n TOutF50Plu\n \n \n \n \n \n \n TOutF<1yr\n \n \n \n \n \n \n TOutM1-4\n \n \n \n \n \n \n TOutM10-14\n \n \n \n \n \n \n TOutM15-19\n \n \n \n \n \n \n TOutM20-24\n \n \n \n \n \n \n TOutM25-29\n \n \n \n \n \n \n TOutM30-34\n \n \n \n \n \n \n TOutM35-39\n \n \n \n \n \n \n TOutM40-44\n \n \n \n \n \n \n TOutM45-49\n \n \n \n \n \n \n TOutM5-9\n \n \n \n \n \n \n TOutM50PLu\n \n \n \n \n \n \n TOutM<1yr\n \n \n \n \n \n \n','2021-09-21 10:52:57',4,'2022-09-23 08:18:33',4,0,NULL,NULL,NULL,'81bde35e-8217-4ef4-988a-f578a52fd5d9'),(1217,'PITC_New_Positive_OPD','HTS Report - OPD location - PITC New Pos ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive_OPD\n HTS Report - OPD location - PITC New Pos \n \n 2021-09-23 11:38:55 UTC\n \n 2023-03-29 21:46: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 1217\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (2191,2190,2192,2139,4791,2143) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 13:38:55',4,'2023-03-29 23:46:24',4,0,NULL,NULL,NULL,'c9db805d-4bea-4f9a-a3ac-0325d0a27fa9'),(1218,'PITC_New_Negative_OPD','HTS Report - OPD location - PITC New Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative_OPD\n HTS Report - OPD location - PITC New Negative\n \n 2021-09-23 13:11:08 UTC\n \n 2023-03-29 21:41: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 1218\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (2191,2190,2192,2139,4791,2143) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:11:08',4,'2023-03-29 23:41:58',4,0,NULL,NULL,NULL,'e6471d7a-2acd-4bb6-9124-d757bc31a72b'),(1219,'PITC_Repeat_Positive_OPD','HTS Report - OPD location - PITC Repeat Pos','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive_OPD\n HTS Report - OPD location - PITC Repeat Pos\n \n 2021-09-23 13:13:09 UTC\n \n 2023-03-29 22:10: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 1219\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (2191,2190,2192,2139,4791,2143) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:13:09',4,'2023-03-30 00:10:02',4,0,NULL,NULL,NULL,'4b40c86a-2709-41dd-be33-d3efc05e2f66'),(1220,'PITC_Repeat_Negative_OPD',' HTS Report - OPD location - PITC Repeat Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative_OPD\n HTS Report - OPD location - PITC Repeat Negative\n \n 2021-09-23 13:20:34 UTC\n \n 2023-03-29 22:02: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 1220\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (2191,2190,2192,2139,4791,2143) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:20:34',4,'2023-03-30 00:02:24',4,0,NULL,NULL,NULL,'99ec373f-d9b7-4eb0-99e4-a245f3b7018d'),(1221,'PITC_New_Positive_Adolescent','HTS Report - Adolescent location - PITC New Pos','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive_Adolescent\n HTS Report - Adolescent location - PITC New Pos\n \n 2021-09-23 13:28:38 UTC\n \n 2023-03-29 21: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 1221\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4236 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:28:38',4,'2023-03-29 23:44:16',4,0,NULL,NULL,NULL,'ca12e57f-dbac-4bef-b6d3-43fa18145d53'),(1222,'PITC_New_Negative_Adolescent','HTS Report - Adolescent location - PITC New Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative_Adolescent\n HTS Report - Adolescent location - PITC New Negative\n \n 2021-09-23 13:32:28 UTC\n \n 2023-03-29 21:38: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 1222\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4236 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:32:28',4,'2023-03-29 23:38:24',4,0,NULL,NULL,NULL,'39bf8113-eca7-440e-b67c-baabc1c1400d'),(1223,'PITC_Repeat_Positive_Adolescent','HTS Report - Adolescent location - PITC Repeat Pos','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive_Adolescent\n HTS Report - Adolescent location - PITC Repeat Pos\n \n 2021-09-23 13:35:10 UTC\n \n 2023-03-29 22:07: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 1223\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4236 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:35:10',4,'2023-03-30 00:07:20',4,0,NULL,NULL,NULL,'117426a7-ca44-4b9b-b4c4-72f565c9b534'),(1224,'PITC_Repeat_Negative_Adolescent',' HTS Report - Adolescent location - PITC Repeat Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative_Adolescent\n HTS Report - Adolescent location - PITC Repeat Negative\n \n 2021-09-23 13:39:06 UTC\n \n 2023-03-29 21: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 1224\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4236 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:39:06',4,'2023-03-29 23:58:42',4,0,NULL,NULL,NULL,'eb4559df-958e-40ff-a863-abdcfcf257e8'),(1225,'PITC_New_Positive_ART','HTS Report - ART location - PITC New Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive_ART\n HTS Report - ART location - PITC New Positive\n \n 2021-09-23 13:46:15 UTC\n \n 2023-03-29 21:44: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 1225\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4234,3632,4816) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:46:15',4,'2023-03-29 23:44:45',4,0,NULL,NULL,NULL,'1590fd93-0b9e-4e42-93b7-98ce50da42a9'),(1226,'PITC_New_Negative_ART','HTS Report - ART location - PITC New Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative_ART\n HTS Report - ART location - PITC New Negative\n \n 2021-09-23 13:47:57 UTC\n \n 2023-03-29 21: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 1226\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4234,3632,4816) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:47:57',4,'2023-03-29 23:39:04',4,0,NULL,NULL,NULL,'d7b22cfb-e38a-4764-8e7c-c1950dee7bb1'),(1227,'PITC_Repeat_Positive_ART','HTS Report - ART location - PITC Repeat Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive_ART\n HTS Report - ART location - PITC Repeat Positive\n \n 2021-09-23 13:49:18 UTC\n \n 2023-03-29 22:08: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 1227\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4234,3632,4816) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:49:18',4,'2023-03-30 00:08:03',4,0,NULL,NULL,NULL,'037fb6a1-3ad9-421d-851b-29b857c36013'),(1228,'PITC_Repeat_Negative_ART','HTS Report - ART location - PITC Repeat Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative_ART\n HTS Report - ART location - PITC Repeat Negative\n \n 2021-09-23 13:50:31 UTC\n \n 2023-03-29 21:59: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 1228\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4234,3632,4816) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 15:50:31',4,'2023-03-29 23:59:13',4,0,NULL,NULL,NULL,'e80c4654-6566-43f8-a397-2ba993465ec0'),(1229,'PITC_New_Positive_Index','HTS Report - Index location - PITC New_Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive_Index\n HTS Report - Index location - PITC New_Positive\n \n 2021-09-23 14:10:52 UTC\n \n 2023-03-29 21:45: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 1229\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4792 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:10:52',4,'2023-03-29 23:45:18',4,0,NULL,NULL,NULL,'d6e893c7-5866-4f27-897d-c4547f2913b8'),(1230,'PITC_New_Negative_Index','HTS Report - Index location - PITC New_Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative_Index\n HTS Report - Index location - PITC New_Negative\n \n 2021-09-23 14:12:40 UTC\n \n 2023-03-29 21: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 1230\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4792 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:12:40',4,'2023-03-29 23:39:57',4,0,NULL,NULL,NULL,'ffc2c83d-60de-4432-9b5d-4b7107ea9961'),(1231,'PITC_Repeat_Positive_Index','HTS Report - Index location - PITC Repeat_Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive_Index\n HTS Report - Index location - PITC Repeat_Positive\n \n 2021-09-23 14:15:09 UTC\n \n 2023-03-29 22:08: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 1231\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4792 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:15:09',4,'2023-03-30 00:08:44',4,0,NULL,NULL,NULL,'d36cc9c3-352f-44cf-b949-3f19a426c39b'),(1232,'PITC_Repeat_Negative_Index',' HTS Report - Index location - PITC Repeat Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative_Index\n HTS Report - Index location - PITC Repeat Negative\n \n 2021-09-23 14:16:30 UTC\n \n 2023-03-29 21:59: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 1232\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4792 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:16:30',4,'2023-03-29 23:59:43',4,0,NULL,NULL,NULL,'2c72c8ff-e656-4dea-9f99-2ffe5885f78b'),(1233,'PITC_New_Positive_MCH','HTS Report - MCH location - PITC New Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive_MCH\n HTS Report - MCH location - PITC New Positive\n \n 2021-09-23 14:21:38 UTC\n \n 2023-03-29 21:45: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 1233\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4233,4790,4789,4788,4963) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:21:38',4,'2023-03-29 23:45:55',4,0,NULL,NULL,NULL,'42157f3d-e92a-4dd5-98ea-a0dff211087e'),(1234,'PITC_New_Negative_MCH','HTS Report - MCH location - PITC New Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative_MCH\n HTS Report - MCH location - PITC New Negative\n \n 2021-09-23 14:23:35 UTC\n \n 2023-03-29 21:40: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 1234\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4233,4790,4789,4788,4963) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:23:35',4,'2023-03-29 23:40:48',4,0,NULL,NULL,NULL,'d7573e09-749d-43ff-a390-fbf74e7209b6'),(1235,'PITC_Repeat_Positive_MCH','HTS Report - MCH location - PITC Repeat Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive_MCH\n HTS Report - MCH location - PITC Repeat Positive\n \n 2021-09-23 14:25:03 UTC\n \n 2023-03-29 22:09: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 1235\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4233,4790,4789,4788,4963) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:25:03',4,'2023-03-30 00:09:22',4,0,NULL,NULL,NULL,'c0b8921b-abf4-43af-b7f7-c9b0aeceb791'),(1236,'PITC_Repeat_Negative_MCH',' HTS Report - MCH location - PITC Repeat Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative_MCH\n HTS Report - MCH location - PITC Repeat Negative\n \n 2021-09-23 14:26:44 UTC\n \n 2023-03-29 22:00: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 1236\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4233,4790,4789,4788,4963) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:26:44',4,'2023-03-30 00:00:18',4,0,NULL,NULL,NULL,'11dc73c3-a8cb-4f9a-9e8b-e5362bba3785'),(1237,'PITC_New_Positive_Outreach','HTS Report - Outreach location - PITC New Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive_Outreach\n HTS Report - Outreach location - PITC New Positive\n \n 2021-09-23 14:31:30 UTC\n \n 2023-03-29 21:47: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 1237\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4796 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:31:30',4,'2023-03-29 23:47:34',4,0,NULL,NULL,NULL,'dbe49be8-2938-4430-85c6-74e3a0e8828d'),(1238,'PITC_New_Negative_Outreach','HTS Report - Outreach location - PITC New Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative_Outreach\n HTS Report - Outreach location - PITC New Negative\n \n 2021-09-23 14:33:43 UTC\n \n 2023-03-29 21:42: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 1238\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4796 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:33:43',4,'2023-03-29 23:42:31',4,0,NULL,NULL,NULL,'d34a7009-d9ca-4bab-baed-7a50cd4e5683'),(1239,'PITC_Repeat_Positive_Outreach',' HTS Report - Outreach location - PITC Repeat Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive_Outreach\n HTS Report - Outreach location - PITC Repeat Positive\n \n 2021-09-23 14:35:30 UTC\n \n 2023-03-29 22:10: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 1239\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4796 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:35:30',4,'2023-03-30 00:10:38',4,0,NULL,NULL,NULL,'79da84b1-174a-4c1a-b472-3c4ef965962f'),(1240,'PITC_Repeat_Negative_Outreach','HTS Report - Outreach location - PITC Repeat Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative_Outreach\n HTS Report - Outreach location - PITC Repeat Negative\n \n 2021-09-23 14:37:27 UTC\n \n 2023-03-29 22: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 1240\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4796 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:37:27',4,'2023-03-30 00:04:57',4,0,NULL,NULL,NULL,'5dceb80b-1b6a-45e6-9670-b209e3960b3b'),(1241,'PITC_New_Positive_SelfTest','HTS Report - Self Test - PITC New Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive_SelfTest\n HTS Report - Self Test - PITC New Positive\n \n 2021-09-23 14:42:18 UTC\n \n 2023-07-27 13:24: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 1241\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1738 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 -- HIV Positive \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n -- AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n Inner Join ( \n select encounter_id,CAST(date_created as Date) as current_conc \n from obs \n where concept_id = 4845 and value_coded = 4847 \n ) as rapids \n on o.encounter_id = rapids.encounter_id \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n \n )as testingform \n on o.person_id = testingform.person_id \n AND testingform.current_conc=rapids.current_conc \n inner join \n ( \n select os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4237 \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 AND patient.voided = 0 AND os.voided = 0 \n \n )as mode \n ON o.person_id = mode.person_id \n AND pitc.encounter = mode.encounter \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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n ) \n \n \n\n','2021-09-23 16:42:18',4,'2023-07-27 15:24:17',4,0,NULL,NULL,NULL,'a649af2e-c356-4c21-aae4-8ecf5325699e'),(1242,'PITC_New_Negative_SelfTest','HTS Report - Self Test - PITC New Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative_SelfTest\n HTS Report - Self Test - PITC New Negative\n \n 2021-09-23 14:45:04 UTC\n \n 2023-03-29 21:43: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 1242\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4237 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:45:04',4,'2023-03-29 23:43:06',4,0,NULL,NULL,NULL,'bfc795aa-cf34-4129-8765-08d8c5a6c265'),(1243,'PITC_Repeat_Positive_SelfTest','HTS Report - Self Test - PITC Repeat Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive_SelfTest\n HTS Report - Self Test - PITC Repeat Positive\n \n 2021-09-23 14:46:15 UTC\n \n 2023-03-29 22:11: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 1243\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4237 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:46:15',4,'2023-03-30 00:11:20',4,0,NULL,NULL,NULL,'1aea70b8-30cf-4ac8-b6b4-296293581073'),(1244,'PITC_Repeat_Negative_SelfTest',' HTS Report - Self Test - PITC Repeat Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative_SelfTest\n HTS Report - Self Test - PITC Repeat Negative\n \n 2021-09-23 14:50:02 UTC\n \n 2023-03-29 22:05: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 1244\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4237 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 16:50:02',4,'2023-03-30 00:05:37',4,0,NULL,NULL,NULL,'fa5d4491-570f-45e0-8e99-74849dffdd1c'),(1245,'PITC_New_Negative_VMMC','HTS Report - VMMC location - PITC New Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Negative_VMMC\n HTS Report - VMMC location - PITC New Negative\n \n 2021-09-23 15:14:55 UTC\n \n 2023-03-29 21:43: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 1245\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:14:55',4,'2023-03-29 23:43:38',4,0,NULL,NULL,NULL,'fe5844f9-5ccc-4ae2-ba58-524a6e4e9443'),(1246,'PITC_New_Positive_VMMC','HTS Report - VMMC location - PITC New Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Positive_VMMC\n HTS Report - VMMC location - PITC New Positive\n \n 2021-09-23 15:17:54 UTC\n \n 2023-03-29 21: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 1246\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:17:54',4,'2023-03-29 23:54:57',4,0,NULL,NULL,NULL,'f48462e3-b31a-4be6-8ce8-e41c3fdb8db3'),(1247,'PITC_Repeat_Negative_VMMC','HTS Report - VMMC location - PITC Repeat Negative','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Negative_VMMC\n HTS Report - VMMC location - PITC Repeat Negative\n \n 2021-09-23 15:19:46 UTC\n \n 2023-03-29 22:06: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 1247\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:19:46',4,'2023-03-30 00:06:14',4,0,NULL,NULL,NULL,'10ee5adc-6d52-4b9a-9ba5-0892bb6277af'),(1248,'PITC_Repeat_Positive_VMMC',' HTS Report - VMMC location - PITC Repeat Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Positive_VMMC\n HTS Report - VMMC location - PITC Repeat Positive\n \n 2021-09-23 15:21:08 UTC\n \n 2023-03-29 22:11: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 1248\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'PITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- PROVIDER INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4227 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:21:08',4,'2023-03-30 00:11:57',4,0,NULL,NULL,NULL,'e1bda5c3-3db3-487d-b7e5-48a817610de0'),(1249,'CITC_New_Negative_Adolescent','CITC_New_Negative_Adolescent','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative_Adolescent\n CITC_New_Negative_Adolescent\n \n 2021-09-23 15:37:47 UTC\n \n 2023-03-29 21:21: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 1249\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4236 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:37:47',4,'2023-03-29 23:21:00',4,0,NULL,NULL,NULL,'85f6e71c-dc8e-4387-b7d7-043e68866f3c'),(1250,'CITC_New_Negative_ART','CITC_New_Negative_ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative_ART\n CITC_New_Negative_ART\n \n 2021-09-23 15:39:50 UTC\n \n 2023-03-29 21:21: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 1250\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4234,3632,4816) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:39:50',4,'2023-03-29 23:21:33',4,0,NULL,NULL,NULL,'367af408-5c3c-4647-8726-a83e52c4ff47'),(1251,'CITC_New_Negative_Index','CITC_New_Negative_Index','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative_Index\n CITC_New_Negative_Index\n \n 2021-09-23 15:41:09 UTC\n \n 2023-03-29 21:22: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 1251\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4792 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:41:09',4,'2023-03-29 23:22:11',4,0,NULL,NULL,NULL,'fbd7dcc2-a114-458f-b17b-93ed30fee5bb'),(1252,'CITC_New_Negative_MCH','CITC_New_Negative_MCH','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative_MCH\n CITC_New_Negative_MCH\n \n 2021-09-23 15:42:38 UTC\n \n 2023-03-29 21: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 1252\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4233,4790,4789,4788,4963) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:42:38',4,'2023-03-29 23:22:43',4,0,NULL,NULL,NULL,'bee2be9a-3388-4e55-9f80-8247bda3b761'),(1253,'CITC_New_Negative_OPD','CITC_New_Negative_OPD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative_OPD\n CITC_New_Negative_OPD\n \n 2021-09-23 15:43:46 UTC\n \n 2023-03-29 21: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 1253\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (2191,2190,2192,2139,4791,2143) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:43:46',4,'2023-03-29 23:23:09',4,0,NULL,NULL,NULL,'20ddc359-4a4b-482e-bf81-822d607c9588'),(1254,'CITC_New_Negative_Outreach','CITC_New_Negative_Outreach','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative_Outreach\n CITC_New_Negative_Outreach\n \n 2021-09-23 15:44:49 UTC\n \n 2023-03-29 21:23: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 1254\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4796 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:44:49',4,'2023-03-29 23:23:40',4,0,NULL,NULL,NULL,'372a9429-574b-4c07-974a-a94004eb0494'),(1255,'CITC_New_Negative_SelfTest','CITC_New_Negative_SelfTest','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative_SelfTest\n CITC_New_Negative_SelfTest\n \n 2021-09-23 15:45:51 UTC\n \n 2023-03-29 21: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 1255\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4237 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:45:51',4,'2023-03-29 23:24:14',4,0,NULL,NULL,NULL,'e37ecdc9-6f00-4ec4-b449-ad6202184cf3'),(1256,'CITC_New_Negative_VMMC','CITC_New_Negative_VMMC','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Negative_VMMC\n CITC_New_Negative_VMMC\n \n 2021-09-23 15:47:06 UTC\n \n 2023-03-29 21: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 1256\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:47:06',4,'2023-03-29 23:24:44',4,0,NULL,NULL,NULL,'acace045-4faa-48c6-8506-0fd76448742c'),(1257,'CITC_New_Positive_Adolescent','CITC_New_Positive_Adolescent','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive_Adolescent\n CITC_New_Positive_Adolescent\n \n 2021-09-23 15:48:57 UTC\n \n 2023-03-29 21:25: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 1257\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4236 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:48:57',4,'2023-03-29 23:25:43',4,0,NULL,NULL,NULL,'0b88b543-501f-404d-8b05-1faea17d8d8b'),(1258,'CITC_New_Positive_ART','CITC_New_Positive_ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive_ART\n CITC_New_Positive_ART\n \n 2021-09-23 15:50:00 UTC\n \n 2023-03-29 21:26: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 1258\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4234,3632,4816) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:50:00',4,'2023-03-29 23:26:13',4,0,NULL,NULL,NULL,'64146038-ebce-479a-aed9-a22a50d3be2c'),(1259,'CITC_New_Positive_Index','CITC_New_Positive_Index','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive_Index\n CITC_New_Positive_Index\n \n 2021-09-23 15:50:59 UTC\n \n 2023-03-29 21:27: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 1259\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4792 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:50:59',4,'2023-03-29 23:27:03',4,0,NULL,NULL,NULL,'1bb82f9f-f0ce-4b5a-9f30-595b8a8874e4'),(1260,'CITC_New_Positive_MCH','CITC_New_Positive_MCH','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive_MCH\n CITC_New_Positive_MCH\n \n 2021-09-23 15:52:21 UTC\n \n 2023-03-29 21:28: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 1260\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4233,4790,4789,4788,4963) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:52:21',4,'2023-03-29 23:28:20',4,0,NULL,NULL,NULL,'cc978652-e959-4011-8ec9-ede5f7eadffa'),(1261,'CITC_New_Positive_OPD','CITC_New_Positive_OPD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive_OPD\n CITC_New_Positive_OPD\n \n 2021-09-23 15:53:34 UTC\n \n 2023-03-29 21:28: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 1261\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (2191,2190,2192,2139,4791,2143) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:53:34',4,'2023-03-29 23:28:58',4,0,NULL,NULL,NULL,'3c5a067c-6576-450a-a2ff-0854a65161e3'),(1262,'CITC_New_Positive_Outreach','CITC_New_Positive_Outreach','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive_Outreach\n CITC_New_Positive_Outreach\n \n 2021-09-23 15:54:37 UTC\n \n 2023-03-29 21:29: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 1262\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4796 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:54:37',4,'2023-03-29 23:29:31',4,0,NULL,NULL,NULL,'87777c2f-4e15-4938-adf5-1ad72278602a'),(1263,'CITC_New_Positive_SelfTest','CITC_New_Positive_SelfTest','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive_SelfTest\n CITC_New_Positive_SelfTest\n \n 2021-09-23 15:55:47 UTC\n \n 2023-03-29 21:33: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 1263\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4237 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:55:47',4,'2023-03-29 23:33:24',4,0,NULL,NULL,NULL,'6ebae90a-62f2-493c-9150-2a2d1a47d356'),(1264,'CITC_New_Positive_VMMC','CITC_New_Positive_VMMC','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Positive_VMMC\n CITC_New_Positive_VMMC\n \n 2021-09-23 15:56:53 UTC\n \n 2023-03-29 21:33: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 1264\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'New' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2147 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:56:53',4,'2023-03-29 23:33:58',4,0,NULL,NULL,NULL,'4814aba2-99d9-4de9-9c9c-167240cfbb51'),(1265,'CITC_Repeat_Negative_Adolescent','CITC_Repeat_Negative_Adolescent','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative_Adolescent\n CITC_Repeat_Negative_Adolescent\n \n 2021-09-23 15:58:44 UTC\n \n 2023-03-29 21: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 1265\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4236 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:58:44',4,'2023-03-29 23:07:15',4,0,NULL,NULL,NULL,'565e2079-5073-435a-bd06-10cdd8bfeb1a'),(1266,'CITC_Repeat_Negative_ART','CITC_Repeat_Negative_ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative_ART\n CITC_Repeat_Negative_ART\n \n 2021-09-23 15:59:50 UTC\n \n 2023-03-29 21:07:59 UTC\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 endDate\n \n java.util.Date\n true\n \n \n 1266\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4234,3632,4816) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 17:59:50',4,'2023-03-29 23:07:59',4,0,NULL,NULL,NULL,'2b13b640-dd8b-4c45-8804-11a7273d0bec'),(1267,'CITC_Repeat_Negative_Index','CITC_Repeat_Negative_Index','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative_Index\n CITC_Repeat_Negative_Index\n \n 2021-09-23 16:01:18 UTC\n \n 2023-03-29 21:09: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 1267\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- REPEAT TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4792 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:01:18',4,'2023-03-29 23:09:28',4,0,NULL,NULL,NULL,'4b278eff-3949-4e7f-b882-beb195486860'),(1268,'CITC_Repeat_Negative_MCH','CITC_Repeat_Negative_MCH','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative_MCH\n CITC_Repeat_Negative_MCH\n \n 2021-09-23 16:02:17 UTC\n \n 2023-03-29 21: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 1268\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4233,4790,4789,4788,4963) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:02:17',4,'2023-03-29 23:10:08',4,0,NULL,NULL,NULL,'1a8d4028-ce12-478f-b787-0b08fdf93d09'),(1269,'CITC_Repeat_Negative_OPD','CITC_Repeat_Negative_OPD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative_OPD\n CITC_Repeat_Negative_OPD\n \n 2021-09-23 16:03:27 UTC\n \n 2023-03-29 21:10: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 1269\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (2191,2190,2192,2139,4791,2143) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:03:27',4,'2023-03-29 23:10:42',4,0,NULL,NULL,NULL,'bc578ea3-8d52-40e1-93bf-91f20b569cd1'),(1271,'CITC_Repeat_Negative_Outreach','CITC_Repeat_Negative_Outreach','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative_Outreach\n CITC_Repeat_Negative_Outreach\n \n 2021-09-23 16:05:51 UTC\n \n 2023-03-29 21:11: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 1271\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4796 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:05:51',4,'2023-03-29 23:11:26',4,0,NULL,NULL,NULL,'c1365a92-6aa6-497b-b492-dc535c2a1081'),(1272,'CITC_Repeat_Negative_SelfTest','CITC_Repeat_Negative_SelfTest','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative_SelfTest\n CITC_Repeat_Negative_SelfTest\n \n 2021-09-23 16:07:53 UTC\n \n 2023-03-29 21:12:52 UTC\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 endDate\n \n java.util.Date\n true\n \n \n 1272\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4237 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:07:53',4,'2023-03-29 23:12:52',4,0,NULL,NULL,NULL,'90b6281c-7a7c-467b-9f9b-fb4c6265ce3a'),(1273,'CITC_Repeat_Negative_VMMC','CITC_Repeat_Negative_VMMC','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Negative_VMMC\n CITC_Repeat_Negative_VMMC\n \n 2021-09-23 16:09:16 UTC\n \n 2023-03-29 21:13: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 1273\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1016 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:09:16',4,'2023-03-29 23:13:30',4,0,NULL,NULL,NULL,'d2cd3398-b123-4da9-8765-ded2bce6c333'),(1274,'CITC_Repeat_Positive_Adolescent','CITC_Repeat_Positive_Adolescent','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive_Adolescent\n CITC_Repeat_Positive_Adolescent\n \n 2021-09-23 16:12:39 UTC\n \n 2023-03-29 21:14: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 1274\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4236 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:12:39',4,'2023-03-29 23:14:44',4,0,NULL,NULL,NULL,'78a793c7-8fb1-482c-a9fd-9ad9bb68df2e'),(1275,'CITC_Repeat_Positive_ART','CITC_Repeat_Positive_ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive_ART\n CITC_Repeat_Positive_ART\n \n 2021-09-23 16:14:08 UTC\n \n 2023-03-29 21:15: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 1275\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4234,3632,4816) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:14:08',4,'2023-03-29 23:15:29',4,0,NULL,NULL,NULL,'c030603d-1fa2-4477-aef8-2214f335513a'),(1276,'CITC_Repeat_Positive_Index','CITC_Repeat_Positive_Index','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive_Index\n CITC_Repeat_Positive_Index\n \n 2021-09-23 16:15:05 UTC\n \n 2023-03-29 21:16: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 1276\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4792 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:15:05',4,'2023-03-29 23:16:06',4,0,NULL,NULL,NULL,'442b5cdb-bb91-421b-a902-b88675b591cc'),(1277,'CITC_Repeat_Positive_MCH','CITC_Repeat_Positive_MCH','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive_MCH\n CITC_Repeat_Positive_MCH\n \n 2021-09-23 16:15:57 UTC\n \n 2023-03-29 21:17: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 1277\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (4233,4790,4789,4788,4963) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:15:57',4,'2023-03-29 23:17:06',4,0,NULL,NULL,NULL,'cdc95d8b-968e-42ae-bc6b-2efeec7afa7b'),(1278,'CITC_Repeat_Positive_Outreach','CITC_Repeat_Positive_Outreach','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive_Outreach\n CITC_Repeat_Positive_Outreach\n \n 2021-09-23 16:16:55 UTC\n \n 2023-03-29 21:18: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 1278\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4796 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:16:55',4,'2023-03-29 23:18:10',4,0,NULL,NULL,NULL,'64cc6744-8909-4965-889a-e0da7a0b3cac'),(1279,'CITC_Repeat_Positive_SelfTest','CITC_Repeat_Positive_SelfTest','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive_SelfTest\n CITC_Repeat_Positive_SelfTest\n \n 2021-09-23 16:17:57 UTC\n \n 2023-03-29 21:18: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 1279\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4237 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:17:57',4,'2023-03-29 23:18:44',4,0,NULL,NULL,NULL,'cf8860a8-6bc2-421d-a339-cfe9a7318a66'),(1280,'CITC_Repeat_Positive_VMMC','CITC_Repeat_Positive_VMMC','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive_VMMC\n CITC_Repeat_Positive_VMMC\n \n 2021-09-23 16:18:57 UTC\n \n 2023-03-29 21:19:25 UTC\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 endDate\n \n java.util.Date\n true\n \n \n 1280\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:18:57',4,'2023-03-29 23:19:25',4,0,NULL,NULL,NULL,'4507f03d-8c79-4090-994e-54780740d9f7'),(1281,'CITC_Repeat_Positive_OPD','CITC_Repeat_Positive_OPD','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Positive_OPD\n CITC_Repeat_Positive_OPD\n \n 2021-09-23 16:20:49 UTC\n \n 2023-03-29 21:17: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 1281\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 \n (SELECT Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'CITC' AS 'HIV_Testing_Initiation' \n , 'Repeat' AS 'Testing_History' , HIV_Status, current_conc, encounter, sort_order \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 (select name from concept_name cn where cn.concept_id = 1016 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n pitc.current_conc, \n o.encounter_id as encounter, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- HTS CLIENTS WITH HIV STATUS BY SEX AND AGE \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 2165 and o.value_coded = 1738 \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 \n -- CLIENT INITIATED TESTING AND COUNSELING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4228 and os.value_coded = 4226 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as pitc \n on o.person_id = pitc.person_id \n AND pitc.encounter = o.encounter_id \n -- NEW TESTER, DOES NOT HAVE HISTORY OF PREVIOUS TESTING \n Inner Join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2137 and os.value_coded = 2146 \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 AND patient.voided = 0 AND os.voided = 0 \n ) as repeater \n on o.person_id = repeater.person_id \n and pitc.current_conc = repeater.current_conc \n \n -- Observation be in HIV Testing form \n inner join ( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 2386 \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 AND patient.voided = 0 AND os.voided = 0 \n )as testingform \n on o.person_id = testingform.person_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 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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age) \n \n \n) AS HTS_Status_Detailed \n \n inner join \n( \n select distinct os.person_id, CAST(os.date_created as Date) as current_conc, os.encounter_id as encounter \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded in (2191,2190,2192,2139,4791,2143) \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 AND patient.voided = 0 AND os.voided = 0 \n group by os.person_id \n )B \n ON B.person_id = HTS_Status_Detailed.Id \n AND HTS_Status_Detailed.encounter = B.encounter) \n \n \n\n','2021-09-23 18:20:49',4,'2023-03-29 23:17:40',4,0,NULL,NULL,NULL,'20044501-f5dc-463d-ab2a-a35acbc603e9'),(1282,'self_test_confirmed_positive','Self Test Confirmed Positive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n self_test_confirmed_positive\n Self Test Confirmed Positive\n \n 2021-09-23 16:51:41 UTC\n \n 2021-09-23 16:53: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 1282\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 \n(SELECT Id \nFROM ( \n(SELECT distinct Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age, Gender, age_group, 'Self-test' AS 'HIV_Testing_Initiation' \n , HIV_Status \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 (select name from concept_name cn where cn.concept_id = 1738 and concept_name_type='FULLY_SPECIFIED') AS HIV_Status, \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 -- HTS SELF TEST STRATEGY \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4845 and value_coded = 4822 \n AND patient.voided = 0 AND o.voided = 0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n -- HAS HIV POSITIVE RESULTS \n AND o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 4844 and os.value_coded = 1738 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND patient.voided = 0 AND o.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 ) AS HTSClients_HIV_Status \n ORDER BY HTSClients_HIV_Status.HIV_Status, HTSClients_HIV_Status.Age)as Pos_Self_Test \n \n \n left outer join \n ( \n select distinct os.person_id \n from obs os \n INNER JOIN patient ON os.person_id = patient.patient_id \n where os.concept_id = 4238 and os.value_coded = 4235 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND patient.voided = 0 AND os.voided = 0 \n -- group by os.person_id \n )B \n ON B.person_id = Pos_Self_Test.Id) \n \n )\n','2021-09-23 18:51:41',4,'2021-09-23 18:53:41',4,0,NULL,NULL,NULL,'0d599d57-f118-4476-b5d6-43c4a3920345'),(1283,'PITC_New_Pos_OPD','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Pos_OPD\n \n \n 2021-09-23 17:10:50 UTC\n \n 2021-09-23 17:12: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 1283\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-23 19:10:50',4,'2021-09-23 19:12:21',4,0,NULL,NULL,NULL,'e135248a-7300-4a02-a819-277e8fdebe14'),(1285,'PITC_HTS_OPD','HTS Report for OPD location','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_OPD\n HTS Report for OPD location\n \n 2021-09-23 17:13:34 UTC\n \n 2021-09-28 13:21: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 1285\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','2021-09-23 19:13:34',4,'2021-09-28 15:21:49',4,0,NULL,NULL,NULL,'e36bd994-3d64-4020-a13a-e3bf5734263b'),(1286,'HTS_OPD Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS_OPD Data Set\n \n 2021-09-23 17:13: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 \n \n','2021-09-23 19:13:49',4,NULL,NULL,0,NULL,NULL,NULL,'d294a5d3-dee6-4b78-b48e-1221d73a2c30'),(1287,'HTS_OPD Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS_OPD Data Set\n \n 2021-09-23 17:13:51 UTC\n \n 2021-09-28 16:35: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 1287\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1yr\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-09-23 19:13:51',4,'2021-09-28 18:35:20',4,0,NULL,NULL,NULL,'81a5c7be-091e-47b2-8379-3dac06f96214'),(1288,'PITC_New_Neg_OPD','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Neg_OPD\n \n \n 2021-09-23 17:25:24 UTC\n \n 2021-09-23 17:26: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 1288\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-23 19:25:24',4,'2021-09-23 19:26:18',4,0,NULL,NULL,NULL,'3aea6253-1697-4ac3-ab0a-c085d8f81762'),(1289,'PITC_Repeat_Pos_OPD','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Pos_OPD\n \n \n 2021-09-23 17:28:09 UTC\n \n 2021-09-23 17:30:12 UTC\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 endDate\n \n java.util.Date\n true\n \n \n 1289\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-23 19:28:09',4,'2021-09-23 19:30:12',4,0,NULL,NULL,NULL,'f38aecb9-6b9f-48b8-91ad-3d6a428630df'),(1290,'PITC_Repeat_Neg_OPD','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Neg_OPD\n \n \n 2021-09-23 17:31:18 UTC\n \n 2021-09-23 17: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 1290\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-23 19:31:18',4,'2021-09-23 19:32:04',4,0,NULL,NULL,NULL,'d7b620d3-c912-4fa9-b9f7-9b9a22443d3a'),(1291,'CITC_New_Pos_OPD','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Pos_OPD\n \n \n 2021-09-23 17:32:43 UTC\n \n 2021-09-23 17:33:30 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n 1291\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-23 19:32:43',4,'2021-09-23 19:33:30',4,0,NULL,NULL,NULL,'a7b1118f-8ce9-4af0-8611-c0d94fe28277'),(1292,'CITC_New_Neg_OPD','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Neg_OPD\n \n \n 2021-09-23 17:33:56 UTC\n \n 2021-09-23 17:34: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 1292\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-23 19:33:56',4,'2021-09-23 19:34:34',4,0,NULL,NULL,NULL,'bea053b1-27d1-4cee-b191-f41df2b51291'),(1293,'CITC_Repeat_Pos_OPD','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Pos_OPD\n \n \n 2021-09-23 17:35:00 UTC\n \n 2021-09-23 17:36: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 1293\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-23 19:35:00',4,'2021-09-23 19:36:28',4,0,NULL,NULL,NULL,'08a34077-6dd2-4b18-b2cf-a998b7fa6c3b'),(1294,'CITC_Repeat_Neg_OPD','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Neg_OPD\n \n \n 2021-09-23 17:36:58 UTC\n \n 2021-09-23 17:37: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 1294\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-23 19:36:58',4,'2021-09-23 19:37:45',4,0,NULL,NULL,NULL,'496ad2d1-f6f1-423e-8584-4304bb3286df'),(1295,'CITC_HTS_OPD','CITC_HTS Report for OPD location','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_OPD\n CITC_HTS Report for OPD location\n \n 2021-09-28 13:51:08 UTC\n \n 2021-09-29 13:02: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 1295\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','2021-09-28 15:51:08',4,'2021-09-29 15:02:03',4,0,NULL,NULL,NULL,'77fca612-86fe-4cbf-98b7-9556c57f11e4'),(1296,'OPD_HTS_CITC Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n OPD_HTS_CITC Data Set\n \n 2021-09-28 13:51:16 UTC\n \n 2021-09-28 14:58: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 1296\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-09-28 15:51:16',4,'2021-09-28 16:58:35',4,0,NULL,NULL,NULL,'16c7f7fe-f944-4c3c-938d-deebb122a333'),(1297,'PITC_New_Neg_Outreach','PITC_New_Neg_Outreach','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Neg_Outreach\n PITC_New_Neg_Outreach\n \n 2021-09-30 13:45:14 UTC\n \n 2021-09-30 13:46: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 1297\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-30 15:45:14',4,'2021-09-30 15:46:33',4,0,NULL,NULL,NULL,'39057cef-8337-4ff3-a8a2-91fa6e5c548d'),(1298,'PITC_New_Pos_Outreach','PITC_New_Pos_Outreach','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Pos_Outreach\n PITC_New_Pos_Outreach\n \n 2021-09-30 13:47:37 UTC\n \n 2021-09-30 13:48: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 1298\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-30 15:47:37',4,'2021-09-30 15:48:31',4,0,NULL,NULL,NULL,'0a9cfa8f-1e23-447d-9392-0fca529a0953'),(1299,'PITC_Repeat_Neg_Outreach','PITC_Repeat_Neg_Outreach','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Neg_Outreach\n PITC_Repeat_Neg_Outreach\n \n 2021-09-30 13:48:59 UTC\n \n 2021-09-30 13:50: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 1299\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-30 15:48:59',4,'2021-09-30 15:50:39',4,0,NULL,NULL,NULL,'c8aae0d9-3f3d-4ce1-b4c7-a143047bb1f9'),(1300,'PITC_Repeat_Pos_Outreach','PITC_Repeat_Pos_Outreach','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Pos_Outreach\n PITC_Repeat_Pos_Outreach\n \n 2021-09-30 13:49:32 UTC\n \n 2021-09-30 13:51: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 1300\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-30 15:49:32',4,'2021-09-30 15:51:02',4,0,NULL,NULL,NULL,'0baa5b16-2c08-43b5-b8b0-f79631c81a65'),(1301,'PITC_HTS_Outreach','HTS Report for Outreach location','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_Outreach\n HTS Report for Outreach location\n \n 2021-09-30 13:52:55 UTC\n \n 2021-09-30 14:51: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 1301\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','2021-09-30 15:52:55',4,'2021-09-30 16:51:37',4,0,NULL,NULL,NULL,'82447585-c743-4981-9ae3-cb2ca701d480'),(1302,'PITC_HTS_Outreach Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_Outreach Data Set\n \n 2021-09-30 13:53:05 UTC\n \n 2021-09-30 14:40: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 1302\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-09-30 15:53:05',4,'2021-09-30 16:40:26',4,0,NULL,NULL,NULL,'617f0c89-e7d6-4e28-b9d0-77c22b59c8e8'); +INSERT INTO `serialized_object` VALUES (1303,'CITC_New_Neg_Outreach','CITC_New_Neg_Outreach','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Neg_Outreach\n CITC_New_Neg_Outreach\n \n 2021-09-30 19:52:49 UTC\n \n 2021-09-30 19:59: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 1303\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-30 21:52:49',4,'2021-09-30 21:59:14',4,0,NULL,NULL,NULL,'d55affa6-233e-42b7-b781-2d35bcb11d20'),(1304,'CITC_New_Pos_Outreach','CITC_New_Pos_Outreach','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Pos_Outreach\n CITC_New_Pos_Outreach\n \n 2021-09-30 19:53:13 UTC\n \n 2021-09-30 20:04: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 1304\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-30 21:53:13',4,'2021-09-30 22:04:23',4,0,NULL,NULL,NULL,'70d48a98-c83c-4d92-83eb-ecbb22050996'),(1305,'CITC_Repeat_Neg_Outreach','CITC_Repeat_Neg_Outreach','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Neg_Outreach\n CITC_Repeat_Neg_Outreach\n \n 2021-09-30 19:54:25 UTC\n \n 2021-09-30 20:06: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 1305\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-30 21:54:25',4,'2021-09-30 22:06:45',4,0,NULL,NULL,NULL,'dcd9c782-fff7-4481-9f61-958f8484b9a0'),(1306,'CITC_Repeat_Pos_Outreach','CITC_Repeat_Pos_Outreach','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Pos_Outreach\n CITC_Repeat_Pos_Outreach\n \n 2021-09-30 19:55:31 UTC\n \n 2021-09-30 20:06: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 1306\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-09-30 21:55:31',4,'2021-09-30 22:06:31',4,0,NULL,NULL,NULL,'37c3dd42-9503-4957-a234-d18cdd62a67a'),(1307,'CITC_HTS_Outreach','CITC_HTS_Outreach','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_Outreach\n CITC_HTS_Outreach\n \n 2021-09-30 20:03:27 UTC\n \n 2021-09-30 20:04: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 1307\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','2021-09-30 22:03:27',4,'2021-09-30 22:04:04',4,0,NULL,NULL,NULL,'6e3130f4-4993-4e26-adce-598c242565e9'),(1308,'CITC_HTS_Outreach Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_Outreach Data Set\n \n 2021-09-30 20:04:04 UTC\n \n 2021-09-30 22:06: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 1308\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-09-30 22:04:04',4,'2021-10-01 00:06:25',4,0,NULL,NULL,NULL,'ac8c58c1-770c-4770-8418-4597c8b55c15'),(1309,' PITC_New_Neg_Adolescent',' PITC_New_Neg_Adolescent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Neg_Adolescent\n PITC_New_Neg_Adolescent\n \n 2021-10-05 20:43:32 UTC\n \n 2021-10-05 20: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 1309\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-05 22:43:32',4,'2021-10-05 22:48:56',4,0,NULL,NULL,NULL,'6aa142db-2786-4b21-beba-0ec77f22b523'),(1310,' PITC_New_Pos_Adolescent',' PITC_New_Pos_Adolescent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Pos_Adolescent\n PITC_New_Pos_Adolescent\n \n 2021-10-05 20:45:02 UTC\n \n 2021-10-05 20:49: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 1310\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-05 22:45:02',4,'2021-10-05 22:49:16',4,0,NULL,NULL,NULL,'8da0c564-e37c-447a-bb9c-81f65a635eae'),(1311,' PITC_Repeat_Neg_Adolescent',' PITC_Repeat_Neg_Adolescent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Neg_Adolescent\n PITC_Repeat_Neg_Adolescent\n \n 2021-10-05 20:46:27 UTC\n \n 2021-10-05 20:50: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 1311\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-05 22:46:27',4,'2021-10-05 22:50:02',4,0,NULL,NULL,NULL,'80d3e806-5077-42e0-9e5d-a89bd8579e73'),(1312,' PITC_Repeat_Pos_Adolescent',' PITC_Repeat_Pos_Adolescent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Pos_Adolescent\n PITC_Repeat_Pos_Adolescent\n \n 2021-10-05 20:47:22 UTC\n \n 2021-10-05 20:50: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 1312\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-05 22:47:22',4,'2021-10-05 22:50:21',4,0,NULL,NULL,NULL,'7ed0ead3-64c7-4529-9b3e-c82025462bb6'),(1313,'PITC_HTS_Adolescent','HTS Report for Adolescent location','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_Adolescent\n HTS Report for Adolescent location\n \n 2021-10-05 20:54:10 UTC\n \n 2021-10-05 20:54: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 1313\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','2021-10-05 22:54:10',4,'2021-10-05 22:54:35',4,0,NULL,NULL,NULL,'7f017fec-79d5-4ea6-87ba-be936e919d6b'),(1314,'PITC_HTS_Adolescent Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_Adolescent Data Set\n \n 2021-10-05 20:54:35 UTC\n \n 2021-10-06 06:00: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 1314\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-05 22:54:35',4,'2021-10-06 08:00:38',4,0,NULL,NULL,NULL,'3559e185-9b49-4159-a276-bee817744132'),(1315,'CITC_New_Neg_Adolescent','CITC_New_Neg_Adolescent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Neg_Adolescent\n CITC_New_Neg_Adolescent\n \n 2021-10-06 09:39:49 UTC\n \n 2021-10-06 09:44: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 1315\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 11:39:49',4,'2021-10-06 11:44:29',4,0,NULL,NULL,NULL,'eb91b86e-c2db-4d3b-8a67-7dc511379d4a'),(1316,'CITC_New_Pos_Adolescent','CITC_New_Pos_Adolescent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Pos_Adolescent\n CITC_New_Pos_Adolescent\n \n 2021-10-06 09:40:53 UTC\n \n 2021-10-06 09:44: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 1316\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 11:40:53',4,'2021-10-06 11:44:45',4,0,NULL,NULL,NULL,'53065d6f-4498-41e0-92f5-907e584e85fa'),(1317,'CITC_Repeat_Neg_Adolescent','CITC_Repeat_Neg_Adolescent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Neg_Adolescent\n CITC_Repeat_Neg_Adolescent\n \n 2021-10-06 09:41:27 UTC\n \n 2021-10-06 09: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 1317\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 11:41:27',4,'2021-10-06 11:45:02',4,0,NULL,NULL,NULL,'787ad098-ef27-4117-9acf-28781458e03e'),(1318,'CITC_Repeat_Pos_Adolescent','CITC_Repeat_Pos_Adolescent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Pos_Adolescent\n CITC_Repeat_Pos_Adolescent\n \n 2021-10-06 09:41:52 UTC\n \n 2021-10-06 09:45: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 1318\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 11:41:52',4,'2021-10-06 11:45:17',4,0,NULL,NULL,NULL,'67dbab08-8fee-479d-a0af-ff4ac7dc8648'),(1319,'CITC_HTS_Adolescent','CITC_HTS_Adolescent','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_Adolescent\n CITC_HTS_Adolescent\n \n 2021-10-06 09:46:57 UTC\n \n 2021-10-06 09:47: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 1319\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','2021-10-06 11:46:57',4,'2021-10-06 11:47:25',4,0,NULL,NULL,NULL,'6992581e-4161-4f22-b90a-36dc1965ccfd'),(1320,'CITC_HTS_Adolescent Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_Adolescent Data Set\n \n 2021-10-06 09:47:25 UTC\n \n 2021-10-06 15:27: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 1320\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-06 11:47:25',4,'2021-10-06 17:27:43',4,0,NULL,NULL,NULL,'4a64819c-e83a-4486-bc35-3b94e45e6285'),(1321,' PITC_New_Neg_MCH',' PITC_New_Neg_MCH','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Neg_MCH\n PITC_New_Neg_MCH\n \n 2021-10-06 15:32:10 UTC\n \n 2021-10-06 15:35: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 1321\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 17:32:10',4,'2021-10-06 17:35:35',4,0,NULL,NULL,NULL,'da4ee526-eb6c-475d-925c-ab56da241de3'),(1322,' PITC_New_Pos_MCH',' PITC_New_Pos_MCH','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Pos_MCH\n PITC_New_Pos_MCH\n \n 2021-10-06 15:32:39 UTC\n \n 2021-10-06 15:35: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 1322\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 17:32:39',4,'2021-10-06 17:35:50',4,0,NULL,NULL,NULL,'b3e9452d-7a33-4d06-ae8c-5e730923eb7b'),(1323,' PITC_Repeat_Neg_MCH',' PITC_Repeat_Neg_MCH','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Neg_MCH\n PITC_Repeat_Neg_MCH\n \n 2021-10-06 15:33:14 UTC\n \n 2021-10-06 15:36: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 1323\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 17:33:14',4,'2021-10-06 17:36:49',4,0,NULL,NULL,NULL,'168f838a-8ac0-43f1-a178-bb24cff130f1'),(1324,' PITC_Repeat_Pos_MCH',' PITC_Repeat_Pos_MCH','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Pos_MCH\n PITC_Repeat_Pos_MCH\n \n 2021-10-06 15:33:43 UTC\n \n 2021-10-06 15:37: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 1324\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 17:33:43',4,'2021-10-06 17:37:03',4,0,NULL,NULL,NULL,'49998468-941c-4817-b3e7-ada1ea8862cc'),(1325,'PITC_HTS_MCH','HTS Report for MCH location','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_MCH\n HTS Report for MCH location\n \n 2021-10-06 15:39:51 UTC\n \n 2021-10-07 04: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 1325\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','2021-10-06 17:39:51',4,'2021-10-07 06:34:03',4,0,NULL,NULL,NULL,'d946548e-a7f9-4115-bcd3-f78afdab092d'),(1326,'PITC_HTS_MCH Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_MCH Data Set\n \n 2021-10-06 15:40:13 UTC\n \n 2021-10-06 21:25: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 1326\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-06 17:40:13',4,'2021-10-06 23:25:14',4,0,NULL,NULL,NULL,'e7bbe762-47b2-4ca9-adcb-64e8b0cd50e1'),(1327,'CITC_New_Pos_MCH','CITC_New_Pos_MCH','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Pos_MCH\n CITC_New_Pos_MCH\n \n 2021-10-06 21:29:56 UTC\n \n 2021-10-06 21:33: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 1327\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 23:29:56',4,'2021-10-06 23:33:10',4,0,NULL,NULL,NULL,'ca78fdaa-e5f6-498e-9781-9cf1f8366220'),(1328,'CITC_New_Neg_MCH','CITC_New_Neg_MCH','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Neg_MCH\n CITC_New_Neg_MCH\n \n 2021-10-06 21:30:12 UTC\n \n 2021-10-06 21:32: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 1328\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 23:30:12',4,'2021-10-06 23:32:49',4,0,NULL,NULL,NULL,'32c4681d-fbde-4aa3-b10c-bf6393b39a4b'),(1329,'CITC_Repeat_Neg_MCH','CITC_Repeat_Neg_MCH','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Neg_MCH\n CITC_Repeat_Neg_MCH\n \n 2021-10-06 21:30:32 UTC\n \n 2021-10-06 21:33: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 1329\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 23:30:32',4,'2021-10-06 23:33:53',4,0,NULL,NULL,NULL,'51f2438c-b8a5-47c2-8703-c04885de774e'),(1330,'CITC_Repeat_Pos_MCH','CITC_Repeat_Pos_MCH','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Pos_MCH\n CITC_Repeat_Pos_MCH\n \n 2021-10-06 21:30:46 UTC\n \n 2021-10-06 21: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 1330\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-06 23:30:46',4,'2021-10-06 23:34:06',4,0,NULL,NULL,NULL,'50a98d1c-3cc7-43e9-824b-dde34f55e120'),(1331,'CITC_HTS_MCH','CITC_HTS_MCH','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_MCH\n CITC_HTS_MCH\n \n 2021-10-06 21:36:13 UTC\n \n 2021-10-06 21:36: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 1331\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','2021-10-06 23:36:13',4,'2021-10-06 23:36:35',4,0,NULL,NULL,NULL,'65873a4c-f706-4491-afc1-1a6ee9f18a35'),(1332,'CITC_HTS_MCH Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_MCH Data Set\n \n 2021-10-06 21:36:35 UTC\n \n 2021-10-06 23:12: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 1332\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-06 23:36:35',4,'2021-10-07 01:12:16',4,0,NULL,NULL,NULL,'545ac344-383c-40fb-b248-f42915e427f5'),(1333,'PITC_New_Neg_Index','PITC_New_Neg_Index','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Neg_Index\n PITC_New_Neg_Index\n \n 2021-10-07 04:25:39 UTC\n \n 2021-10-07 04:29: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 1333\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 06:25:39',4,'2021-10-07 06:29:23',4,0,NULL,NULL,NULL,'4c7fd830-a0c3-4e72-950c-05b972769d55'),(1334,'PITC_New_Pos_Index','PITC_New_Pos_Index','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Pos_Index\n PITC_New_Pos_Index\n \n 2021-10-07 04:25:56 UTC\n \n 2021-10-07 04:29: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 1334\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 06:25:56',4,'2021-10-07 06:29:46',4,0,NULL,NULL,NULL,'a4977c25-a493-47af-a8c9-7add78c9adf9'),(1335,'PITC_Repeat_Neg_Index','PITC_Repeat_Neg_Index','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Neg_Index\n PITC_Repeat_Neg_Index\n \n 2021-10-07 04:26:41 UTC\n \n 2021-10-07 04:30: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 1335\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 06:26:41',4,'2021-10-07 06:30:04',4,0,NULL,NULL,NULL,'e3e5f2be-eb19-4c33-8b0c-72d67e791ab4'),(1336,'PITC_Repeat_Pos_Index','PITC_Repeat_Pos_Index','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Pos_Index\n PITC_Repeat_Pos_Index\n \n 2021-10-07 04:26:54 UTC\n \n 2021-10-07 04:30: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 1336\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 06:26:54',4,'2021-10-07 06:30:41',4,0,NULL,NULL,NULL,'dbb343c4-6946-4a13-b6dc-e2a2e77dfaed'),(1337,'PITC_HTS_Index','HTS Report for Index Clients','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_Index\n HTS Report for Index Clients\n \n 2021-10-07 04:33:41 UTC\n \n 2021-10-07 04:34: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 1337\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','2021-10-07 06:33:41',4,'2021-10-07 06:34:05',4,0,NULL,NULL,NULL,'ce0ad8fd-bde8-4fce-be69-23e238f249bb'),(1338,'PITC_HTS_Index Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_Index Data Set\n \n 2021-10-07 04:34:04 UTC\n \n 2021-10-07 06: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 1338\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-07 06:34:04',4,'2021-10-07 08:43:10',4,0,NULL,NULL,NULL,'6425e4dd-681d-43a9-912b-3b0b6367a969'),(1339,'CITC_New_Neg_Index','CITC_New_Neg_Index','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Neg_Index\n CITC_New_Neg_Index\n \n 2021-10-07 07:25:59 UTC\n \n 2021-10-07 07:31: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 1339\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 09:25:59',4,'2021-10-07 09:31:52',4,0,NULL,NULL,NULL,'976b5e87-e40a-4e5f-822b-2b41ae0f7ecc'),(1340,'CITC_New_Pos_Index','CITC_New_Pos_Index','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Pos_Index\n CITC_New_Pos_Index\n \n 2021-10-07 07:26:54 UTC\n \n 2021-10-07 07:30: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 1340\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 09:26:54',4,'2021-10-07 09:30:52',4,0,NULL,NULL,NULL,'5286eeaa-dfe4-4d69-ba48-8931a03a1a8d'),(1341,'CITC_Repeat_Neg_Index','CITC_Repeat_Neg_Index','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Neg_Index\n CITC_Repeat_Neg_Index\n \n 2021-10-07 07:27:26 UTC\n \n 2021-10-07 07:31: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 1341\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 09:27:26',4,'2021-10-07 09:31:17',4,0,NULL,NULL,NULL,'ad69563a-424d-4772-8869-d366a9d92307'),(1342,'CITC_Repeat_Pos_Index','CITC_Repeat_Pos_Index','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Pos_Index\n CITC_Repeat_Pos_Index\n \n 2021-10-07 07:28:27 UTC\n \n 2021-10-07 07: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 1342\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 09:28:27',4,'2021-10-07 09:31:36',4,0,NULL,NULL,NULL,'e1cc0a62-96a8-4f4c-9d05-49e3ccd97fed'),(1343,'CITC_HTS_Index','CITC_HTS_Index','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_Index\n CITC_HTS_Index\n \n 2021-10-07 07:33:43 UTC\n \n 2021-10-07 07:34: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 1343\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','2021-10-07 09:33:43',4,'2021-10-07 09:34:04',4,0,NULL,NULL,NULL,'dce22475-86fa-436c-9e0c-d1af120f9cf2'),(1344,'CITC_HTS_Index Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_Index Data Set\n \n 2021-10-07 07:34:04 UTC\n \n 2021-10-07 09:01: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 1344\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-07 09:34:04',4,'2021-10-07 11:01:32',4,0,NULL,NULL,NULL,'5618efc3-69e9-4c64-adaa-741ed768cbd3'),(1345,'PITC_New_Neg_ART','PITC_New_Neg_ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Neg_ART\n PITC_New_Neg_ART\n \n 2021-10-07 10:13:58 UTC\n \n 2021-10-07 10:16: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 1345\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 12:13:58',4,'2021-10-07 12:16:09',4,0,NULL,NULL,NULL,'6d5bf688-5a2f-4616-82e2-c01a54f14722'),(1346,'PITC_New_Pos_ART','PITC_New_Pos_ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Pos_ART\n PITC_New_Pos_ART\n \n 2021-10-07 10:14:22 UTC\n \n 2021-10-07 10:16: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 1346\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 12:14:22',4,'2021-10-07 12:16:24',4,0,NULL,NULL,NULL,'ea06ed88-160a-467d-9417-76fdb0d46941'),(1347,'PITC_Repeat_Neg_ART','PITC_Repeat_Neg_ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Neg_ART\n PITC_Repeat_Neg_ART\n \n 2021-10-07 10:14:49 UTC\n \n 2021-10-07 10:17: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 1347\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 12:14:49',4,'2021-10-07 12:17:02',4,0,NULL,NULL,NULL,'44e7f485-5997-4262-8fad-c7e92dc4fba5'),(1348,'PITC_Repeat_Pos_ART','PITC_Repeat_Pos_ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Pos_ART\n PITC_Repeat_Pos_ART\n \n 2021-10-07 10:15:14 UTC\n \n 2021-10-07 10:17: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 1348\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 12:15:14',4,'2021-10-07 12:17:16',4,0,NULL,NULL,NULL,'7b43f84d-eb38-48ea-a8c4-7600c51472bf'),(1349,'PITC_HTS_ART','HTS Report for ART Location Clients','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_ART\n HTS Report for ART Location Clients\n \n 2021-10-07 10:26:07 UTC\n \n 2021-10-07 10: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 1349\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','2021-10-07 12:26:07',4,'2021-10-07 12:26:32',4,0,NULL,NULL,NULL,'f75d35bb-2331-4d53-9b78-4caa525d469d'),(1350,'PITC_HTS_ART Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_ART Data Set\n \n 2021-10-07 10:26:32 UTC\n \n 2021-10-07 11:44: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 1350\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-07 12:26:32',4,'2021-10-07 13:44:24',4,0,NULL,NULL,NULL,'48195b40-79bc-4e0e-8157-9001e4389381'),(1351,'CITC_HTS_ART','CITC_HTS_ART','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_ART\n CITC_HTS_ART\n \n 2021-10-07 13:58:15 UTC\n \n 2021-10-07 13:58: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 1351\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','2021-10-07 15:58:15',4,'2021-10-07 15:58:32',4,0,NULL,NULL,NULL,'9ee564ea-f127-40f9-89f3-e6d25a9382a2'),(1352,'CITC_HTS_ART Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_ART Data Set\n \n 2021-10-07 13:58:32 UTC\n \n 2024-05-20 17:37: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 1352\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-07 19:28:32',4,'2024-05-20 23:07:03',4,0,NULL,NULL,NULL,'068e94f1-8873-42de-a660-d8f239c4858c'),(1353,'CITC_New_Neg_ART','CITC_New_Neg_ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Neg_ART\n CITC_New_Neg_ART\n \n 2021-10-07 13:59:29 UTC\n \n 2021-10-07 14:02: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 1353\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 15:59:29',4,'2021-10-07 16:02:13',4,0,NULL,NULL,NULL,'8d97fedb-8b2e-4a68-8adb-82f0f4a9add9'),(1354,'CITC_New_Pos_ART','CITC_New_Pos_ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Pos_ART\n CITC_New_Pos_ART\n \n 2021-10-07 13:59:52 UTC\n \n 2021-10-07 14:02: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 1354\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 15:59:52',4,'2021-10-07 16:02:30',4,0,NULL,NULL,NULL,'dacc0b51-b2c6-42c8-a9d8-22751d857b0f'),(1355,'CITC_Repeat_Pos_ART','CITC_Repeat_Pos_ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Pos_ART\n CITC_Repeat_Pos_ART\n \n 2021-10-07 14:00:29 UTC\n \n 2021-10-07 14:03: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 1355\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 16:00:29',4,'2021-10-07 16:03:06',4,0,NULL,NULL,NULL,'0e5f59f7-089a-4da2-9592-fd5d7b2e3160'),(1356,'CITC_Repeat_Neg_ART','CITC_Repeat_Neg_ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Neg_ART\n CITC_Repeat_Neg_ART\n \n 2021-10-07 14:01:00 UTC\n \n 2021-10-07 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 1356\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 16:01:00',4,'2021-10-07 16:02:53',4,0,NULL,NULL,NULL,'df3ebc14-329c-41a7-b8d7-e2be98f7ce77'),(1357,'PITC_New_Neg_SelfTest','PITC_New_Neg_SelfTest','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Neg_SelfTest\n PITC_New_Neg_SelfTest\n \n 2021-10-07 20:57:55 UTC\n \n 2021-10-07 21:01: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 1357\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 22:57:55',4,'2021-10-07 23:01:55',4,0,NULL,NULL,NULL,'69df4bb7-ba58-44b6-ba62-5a4f7890b8f1'),(1358,'PITC_New_Pos_SelfTest','PITC_New_Pos_SelfTest','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Pos_SelfTest\n PITC_New_Pos_SelfTest\n \n 2021-10-07 20:58:22 UTC\n \n 2021-10-07 21:02: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 1358\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 22:58:22',4,'2021-10-07 23:02:12',4,0,NULL,NULL,NULL,'e826a2b0-18e7-4996-8f74-1db38549a861'),(1359,'PITC_Repeat_Neg_SelfTest','PITC_Repeat_Neg_SelfTest','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Neg_SelfTest\n PITC_Repeat_Neg_SelfTest\n \n 2021-10-07 20:59:27 UTC\n \n 2021-10-07 21:02: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 1359\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 22:59:27',4,'2021-10-07 23:02:31',4,0,NULL,NULL,NULL,'0db20958-582a-4b50-ba86-49b9ef0f64e7'),(1360,'PITC_Repeat_Pos_SelfTest','PITC_Repeat_Pos_SelfTest','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Pos_SelfTest\n PITC_Repeat_Pos_SelfTest\n \n 2021-10-07 20:59:42 UTC\n \n 2021-10-07 21:02: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 1360\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 22:59:42',4,'2021-10-07 23:02:45',4,0,NULL,NULL,NULL,'3708255a-1b1a-421d-a0f1-838a320fa6f4'),(1361,'PITC_HTS_SelfTest','HTS Report for Self Test Clients','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_SelfTest\n HTS Report for Self Test Clients\n \n 2021-10-07 21:05:37 UTC\n \n 2021-10-07 21:05: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 1361\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','2021-10-07 23:05:37',4,'2021-10-07 23:05:45',4,0,NULL,NULL,NULL,'b61f2060-1d4b-4bd7-af32-67db98d50032'),(1362,'PITC_HTS_SelfTest Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_SelfTest Data Set\n \n 2021-10-07 21:05:45 UTC\n \n 2021-10-11 20:55: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 1362\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-07 23:05:45',4,'2021-10-11 22:55:42',4,0,NULL,NULL,NULL,'8e37cf0b-426f-41d1-b2f6-c2a2fc4ca11b'),(1363,' CITC_New_Neg_SelfTest',' CITC_New_Neg_SelfTest','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Neg_SelfTest\n CITC_New_Neg_SelfTest\n \n 2021-10-07 21:50:17 UTC\n \n 2021-10-07 21:53: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 1363\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 23:50:17',4,'2021-10-07 23:53:11',4,0,NULL,NULL,NULL,'4f421a8f-f47c-4c7c-b9ee-645c7598c190'),(1364,' CITC_New_Pos_SelfTest',' CITC_New_Pos_SelfTest','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Pos_SelfTest\n CITC_New_Pos_SelfTest\n \n 2021-10-07 21:50:51 UTC\n \n 2021-10-07 21:53: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 1364\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 23:50:51',4,'2021-10-07 23:53:24',4,0,NULL,NULL,NULL,'b0c652de-795a-49ea-8174-ad6f6876657d'),(1365,' CITC_Repeat_Neg_SelfTest',' CITC_Repeat_Neg_SelfTest','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Neg_SelfTest\n CITC_Repeat_Neg_SelfTest\n \n 2021-10-07 21:51:38 UTC\n \n 2021-10-07 21: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 1365\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 23:51:38',4,'2021-10-07 23:53:44',4,0,NULL,NULL,NULL,'e2d26faf-850c-47a9-929d-2d083f7e8493'),(1366,' CITC_Repeat_Pos_SelfTest',' CITC_Repeat_Pos_SelfTest','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Pos_SelfTest\n CITC_Repeat_Pos_SelfTest\n \n 2021-10-07 21:51:56 UTC\n \n 2021-10-07 21:56: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 1366\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-07 23:51:56',4,'2021-10-07 23:56:36',4,0,NULL,NULL,NULL,'8a73a6fd-b0fe-47f7-b291-63dd42af9ada'),(1367,'CITC_HTS_SelfTest','CITC_HTS_SelfTest','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_SelfTest\n CITC_HTS_SelfTest\n \n 2021-10-07 21:57:35 UTC\n \n 2021-10-07 21:57: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 1367\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','2021-10-07 23:57:35',4,'2021-10-07 23:57:43',4,0,NULL,NULL,NULL,'bebe6363-836b-48d2-9803-c0e626cb50aa'),(1368,'CITC_HTS_SelfTest Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_SelfTest Data Set\n \n 2021-10-07 21:57:43 UTC\n \n 2021-10-08 12: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 1368\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-07 23:57:43',4,'2021-10-08 14:58:31',4,0,NULL,NULL,NULL,'a4a5bca8-1758-4080-a156-a84df7a62c29'),(1369,'PITC_New_Neg_VMMC','PITC_New_Neg_VMMC','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Neg_VMMC\n PITC_New_Neg_VMMC\n \n 2021-10-08 13:02:52 UTC\n \n 2021-10-08 13:05: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 1369\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-08 15:02:52',4,'2021-10-08 15:05:39',4,0,NULL,NULL,NULL,'d7fc1236-45c7-43d2-9333-bf39b31047a6'),(1370,'PITC_New_Pos_VMMC','PITC_New_Pos_VMMC','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_New_Pos_VMMC\n PITC_New_Pos_VMMC\n \n 2021-10-08 13:03:05 UTC\n \n 2021-10-08 13:06: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 1370\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-08 15:03:05',4,'2021-10-08 15:06:03',4,0,NULL,NULL,NULL,'82030723-8eb6-48ab-aaaf-0b747daaff1c'),(1371,'PITC_Repeat_Pos_VMMC','PITC_Repeat_Pos_VMMC','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Pos_VMMC\n PITC_Repeat_Pos_VMMC\n \n 2021-10-08 13:03:43 UTC\n \n 2021-10-08 13:06: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 1371\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-08 15:03:43',4,'2021-10-08 15:06:32',4,0,NULL,NULL,NULL,'ab25dc35-65f6-444d-82a0-71167a014c3b'),(1372,'PITC_Repeat_Neg_VMMC','PITC_Repeat_Neg_VMMC','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_Repeat_Neg_VMMC\n PITC_Repeat_Neg_VMMC\n \n 2021-10-08 13:04:03 UTC\n \n 2021-10-08 13:06: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 1372\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-08 15:04:03',4,'2021-10-08 15:06:22',4,0,NULL,NULL,NULL,'236df974-039e-411b-9ce8-09e74f743950'),(1373,'PITC_HTS_VMMC','PITC_HTS_VMMC','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_VMMC\n PITC_HTS_VMMC\n \n 2021-10-08 13:07:49 UTC\n \n 2021-10-08 13:08: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 1373\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','2021-10-08 15:07:49',4,'2021-10-08 15:08:14',4,0,NULL,NULL,NULL,'a58c74c3-1edc-4d4b-8ac2-0ce3e4839c7d'),(1374,'PITC_HTS_VMMC Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PITC_HTS_VMMC Data Set\n \n 2021-10-08 13:08:14 UTC\n \n 2021-10-09 23:08: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 1374\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-08 15:08:14',4,'2021-10-10 01:08:00',4,0,NULL,NULL,NULL,'43f1ef2d-1b0d-46cf-96d3-f357f2d893ab'),(1375,'CITC_New_Neg_VMMC','CITC_New_Neg_VMMC','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Neg_VMMC\n CITC_New_Neg_VMMC\n \n 2021-10-09 22:54:44 UTC\n \n 2021-10-09 22:59: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 1375\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-10 00:54:44',4,'2021-10-10 00:59:55',4,0,NULL,NULL,NULL,'e735dc8b-4e55-46b0-98be-9d35609cdcd1'),(1376,'CITC_New_Pos_VMMC','CITC_New_Pos_VMMC','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_New_Pos_VMMC\n CITC_New_Pos_VMMC\n \n 2021-10-09 22:54:57 UTC\n \n 2021-10-09 23:00: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 1376\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-10 00:54:57',4,'2021-10-10 01:00:23',4,0,NULL,NULL,NULL,'33e10e5c-b210-4364-bb0a-834ef9fef156'),(1377,'CITC_Repeat_Neg_VMMC','CITC_Repeat_Neg_VMMC','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Neg_VMMC\n CITC_Repeat_Neg_VMMC\n \n 2021-10-09 22:55:46 UTC\n \n 2021-10-09 23:00: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 1377\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-10 00:55:46',4,'2021-10-10 01:00:47',4,0,NULL,NULL,NULL,'787c96e2-053c-4c5a-bac9-e6b2cdc11b3b'),(1378,'CITC_Repeat_Pos_VMMC','CITC_Repeat_Pos_VMMC','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_Repeat_Pos_VMMC\n CITC_Repeat_Pos_VMMC\n \n 2021-10-09 22:56:57 UTC\n \n 2021-10-09 23:02: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 1378\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-10-10 00:56:57',4,'2021-10-10 01:02:21',4,0,NULL,NULL,NULL,'abbf2da2-d3f1-4ec4-bcf6-bc4f172771c2'),(1379,'CITC_HTS_VMMC','CITC_HTS_VMMC','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_VMMC\n CITC_HTS_VMMC\n \n 2021-10-09 23:06:10 UTC\n \n 2021-10-09 23:06: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 1379\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','2021-10-10 01:06:10',4,'2021-10-10 01:06:57',4,0,NULL,NULL,NULL,'893154ae-6213-4759-aaad-6662e595eabe'),(1380,'CITC_HTS_VMMC Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CITC_HTS_VMMC Data Set\n \n 2021-10-09 23:06:57 UTC\n \n 2021-10-10 22:32: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 1380\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n \n \n \n \n NNegF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegF25-29\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegF30-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegF35-39\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegF40-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegF50Plu\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NNegM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n NNegM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n NNegM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n NNegM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n NNegM25-29\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n NNegM30-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n NNegM35-39\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n NNegM40-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n NNegM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n NNegM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n NNegM50Plu\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n NNegM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n NPosF1-4\n \n \n \n \n \n \n \n \n \n NPosF10-14\n \n \n \n \n \n \n NPosF15-19\n \n \n \n \n \n \n NPosF20-24\n \n \n \n \n \n \n NPosF25-29\n \n \n \n \n \n \n NPosF30-34\n \n \n \n \n \n \n NPosF35-39\n \n \n \n \n \n \n NPosF40-44\n \n \n \n \n \n \n NPosF45-49\n \n \n \n \n \n \n NPosF5-9\n \n \n \n \n \n \n NPosF50Plu\n \n \n \n \n \n \n NPosF<1\n \n \n \n \n \n \n NPosM1-4\n \n \n \n \n \n \n NPosM10-14\n \n \n \n \n \n \n NPosM15-19\n \n \n \n \n \n \n NPosM20-24\n \n \n \n \n \n \n NPosM25-29\n \n \n \n \n \n \n NPosM30-34\n \n \n \n \n \n \n NPosM35-39\n \n \n \n \n \n \n NPosM40-44\n \n \n \n \n \n \n NPosM45-49\n \n \n \n \n \n \n NPosM5-9\n \n \n \n \n \n \n NPosM50Plu\n \n \n \n \n \n \n NPosM<1\n \n \n \n \n \n \n RNegF1-4\n \n \n \n \n \n \n \n \n \n RNegF10-14\n \n \n \n \n \n \n RNegF15-19\n \n \n \n \n \n \n RNegF20-24\n \n \n \n \n \n \n RNegF25-29\n \n \n \n \n \n \n RNegF30-34\n \n \n \n \n \n \n RNegF35-39\n \n \n \n \n \n \n RNegF40-44\n \n \n \n \n \n \n RNegF45-49\n \n \n \n \n \n \n RNegF5-9\n \n \n \n \n \n \n RNegF50Plu\n \n \n \n \n \n \n RNegF<1\n \n \n \n \n \n \n RNegM1-4\n \n \n \n \n \n \n RNegM10-14\n \n \n \n \n \n \n RNegM15-19\n \n \n \n \n \n \n RNegM20-24\n \n \n \n \n \n \n RNegM25-29\n \n \n \n \n \n \n RNegM30-34\n \n \n \n \n \n \n RNegM35-39\n \n \n \n \n \n \n RNegM40-44\n \n \n \n \n \n \n RNegM45-49\n \n \n \n \n \n \n RNegM5-9\n \n \n \n \n \n \n RNegM50Plu\n \n \n \n \n \n \n RNegM<1\n \n \n \n \n \n \n RPosF1-4\n \n \n \n \n \n \n \n \n \n RPosF10-14\n \n \n \n \n \n \n RPosF15-19\n \n \n \n \n \n \n RPosF20-24\n \n \n \n \n \n \n RPosF25-29\n \n \n \n \n \n \n RPosF30-34\n \n \n \n \n \n \n RPosF35-39\n \n \n \n \n \n \n RPosF40-44\n \n \n \n \n \n \n RPosF45-49\n \n \n \n \n \n \n RPosF5-9\n \n \n \n \n \n \n RPosF50Plu\n \n \n \n \n \n \n RPosF<1\n \n \n \n \n \n \n RPosM1-4\n \n \n \n \n \n \n RPosM10-14\n \n \n \n \n \n \n RPosM15-19\n \n \n \n \n \n \n RPosM20-24\n \n \n \n \n \n \n RPosM25-29\n \n \n \n \n \n \n RPosM30-34\n \n \n \n \n \n \n RPosM35-39\n \n \n \n \n \n \n RPosM40-44\n \n \n \n \n \n \n RPosM45-49\n \n \n \n \n \n \n RPosM5-9\n \n \n \n \n \n \n RPosM50Plu\n \n \n \n \n \n \n RPosM<1\n \n \n \n \n \n \n','2021-10-10 01:06:57',4,'2021-10-11 00:32:14',4,0,NULL,NULL,NULL,'03501008-0bd0-444d-9563-ccbc878fa540'),(1381,'Missed Appointments Under 28 Days Quarterly','Missed Appointments Under 28 Days for quarterly reporting','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Missed Appointments Under 28 Days Quarterly\n Missed Appointments Under 28 Days for quarterly reporting\n \n 2021-11-24 11:15:40 UTC\n \n 2021-11-24 12:16: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 1381\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','2021-11-24 13:15:40',4,'2021-11-24 14:16:41',4,0,NULL,NULL,NULL,'a8c08a78-5ad7-47d0-a164-32023f01d8c3'),(1382,'Missed Under 28 Days Quarterly Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Missed Under 28 Days Quarterly Data Set\n \n 2021-11-24 11:15:50 UTC\n \n 2021-11-24 11:36: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 1382\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n MissedF1-4\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_Finer_Age\n 01-04yrs\n \n \n \n \n \n MissedF10-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n MissedF15-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n MissedF20-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n MissedF25-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n MissedF30-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n MissedF35-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n MissedF40-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n MissedF45-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n MissedF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n MissedF50P\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n MissedF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n MissedM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n MissedM10-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n MissedM15-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n MissedM20-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n MissedM25-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n MissedM30-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n MissedM35-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n MissedM40-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n MissedM45-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n MissedM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n MissedM50P\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n MissedM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n','2021-11-24 13:15:50',4,'2021-11-24 13:36:46',4,0,NULL,NULL,NULL,'d465ee4d-712a-468a-afbb-69a049e009c5'),(1383,'Test - Intakes Percentage','Test - Intakes Percentage','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Test - Intakes Percentage\n Test - Intakes Percentage\n \n 2021-12-08 11:44:27 UTC\n \n 2021-12-08 11:45: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 1383\n','2021-12-08 13:44:27',4,'2021-12-08 13:45:08',4,0,NULL,NULL,NULL,'25bec7c7-30cd-49dd-9995-73b72f766ab7'),(1384,'TPT Started eRegister Process Report Weekly','TPT Started for eRegister Process Report','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TPT Started eRegister Process Report Weekly\n TPT Started for eRegister Process Report\n \n 2021-12-08 14:52:04 UTC\n \n 2021-12-08 16:16: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 1384\n Select Id \nfrom \n(select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier \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 )as A \n \n where Id in ( \n select distinct patient.patient_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n where concept_id = 2227 and value_coded = 2146 \n AND o.obs_datetime >=:startDate and o.obs_datetime <=:endDate \n \n )\n','2021-12-08 16:52:04',4,'2021-12-08 18:16:37',4,0,NULL,NULL,NULL,'90367439-c46f-4021-9858-29280bb738c7'),(1385,'TPT Started this Month','TPT Started this Month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TPT Started this Month\n TPT Started this Month\n \n 2021-12-08 16:20:18 UTC\n \n 2021-12-08 16:20: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 1385\n Select Id \nfrom \n(select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier \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 )as A \n \n where Id in ( \n select distinct patient.patient_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n where concept_id = 2227 and value_coded = 2146 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n )\n','2021-12-08 18:20:18',4,'2021-12-08 18:20:42',4,0,NULL,NULL,NULL,'62e8947b-9360-430f-9708-f61d0adb8cf8'),(1386,'TPT Completed this Month','TPT Completed this Month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TPT Completed this Month\n TPT Completed this Month\n \n 2021-12-13 12:12:58 UTC\n \n 2021-12-13 12:13: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 1386\n Select Id \nfrom \n(select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier \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 )as A \n \n where Id in ( \n select distinct os.person_id \n from obs os \n where concept_id = 4821 \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','2021-12-13 14:12:58',4,'2021-12-13 14:13:15',4,0,NULL,NULL,NULL,'05b50fa0-aa34-4c91-b02e-cd4e159533f1'),(1387,'TPT Completed eRegister Process Report Weekly','TPT Completed eRegister Process Report Weekly','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TPT Completed eRegister Process Report Weekly\n TPT Completed eRegister Process Report Weekly\n \n 2021-12-13 12:22:47 UTC\n \n 2021-12-13 12:23: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 1387\n Select Id \nfrom \n(select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier \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 )as A \n \n where Id in ( \n select distinct patient.patient_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n where concept_id = 4821 \n AND o.obs_datetime >=:startDate and o.obs_datetime <=:endDate \n \n )\n','2021-12-13 14:22:47',4,'2021-12-13 14:23:06',4,0,NULL,NULL,NULL,'3bc4a33c-71d7-483f-8c8e-db247e44e2bc'),(1388,'VL-04 VL tests performed_recent_3months','VL-04 VL tests performed in the recent 3 months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n VL-04 VL tests performed_recent_3months\n VL-04 VL tests performed in the recent 3 months\n \n 2021-12-15 13:35:47 UTC\n \n 2021-12-16 09:05: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 1388\n Select person_id \nFROM \n(select oss.person_id, MAX(oss.obs_datetime) as max_observation,CAST(Max(oss.value_datetime) as DATE) as Blood_Drawn_Date \n from obs oss \n where oss.concept_id = 4267 and oss.voided=0 \n and oss.value_datetime BETWEEN DATE(DATE_ADD(CAST(:endDate AS DATE), INTERVAL -3 MONTH)) AND date_add(cast(:endDate as datetime), interval 1 day) \n group by oss.person_id) as vl_tests_preformed\n','2021-12-15 15:35:47',4,'2021-12-16 11:05:21',4,0,NULL,NULL,NULL,'04eb3953-22d9-4733-aa50-4a8ed4742edf'),(1389,'TPT Continued eRegister Process Report Weekly','Clients Currently on TPT - eRegister Process Report Weekly','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TPT Continued eRegister Process Report Weekly\n Clients Currently on TPT - eRegister Process Report Weekly\n \n 2021-12-16 10:37:22 UTC\n \n 2021-12-16 10:51: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 1389\n Select Id \nfrom \n(select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier \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 )as A \n \n where Id in ( \n select distinct patient.patient_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n where concept_id = 2227 -- and value_coded = 2146 \n AND o.obs_datetime >=:startDate and o.obs_datetime <=:endDate \n \n )\n','2021-12-16 12:37:22',4,'2021-12-16 12:51:15',4,0,NULL,NULL,NULL,'2a45ccbb-5d49-46a5-9c14-86a68c658c0f'),(1390,'TPT Continuing this Month','Clients Continuing TPT this month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TPT Continuing this Month\n Clients Continuing TPT this month\n \n 2021-12-16 10:50:30 UTC\n \n 2021-12-16 10:52: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 1390\n Select Id \nfrom \n(select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier \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 )as A \n \n where Id in ( \n select distinct os.person_id \n from obs os \n where concept_id = 4821 \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','2021-12-16 12:50:30',4,'2021-12-16 12:52:57',4,0,NULL,NULL,NULL,'8b56b3a8-d45a-413e-81d9-b47db2336814'),(1391,'CI54:TPT Started_Weekly','CI54:TPT Started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI54:TPT Started_Weekly\n CI54:TPT Started\n \n 2021-12-16 11:02:11 UTC\n \n 2021-12-16 11:04: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 1391\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 13:02:11',4,'2021-12-16 13:04:49',4,0,NULL,NULL,NULL,'d12bddcf-0bfa-4c0b-96d4-fed20d3251d4'),(1392,'CI55:TPT Continued Weekly','CI55:TPT Continued Weekly','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI55:TPT Continued Weekly\n CI55:TPT Continued Weekly\n \n 2021-12-16 11:06:12 UTC\n \n 2021-12-16 11:07: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 1392\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 13:06:12',4,'2021-12-16 13:07:06',4,0,NULL,NULL,NULL,'6444a6c5-e484-4a40-911e-98ed6c43112d'),(1393,'CI56:TPT Completed Weekly','CI56:TPT Completed Weekly','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI56:TPT Completed Weekly\n CI56:TPT Completed Weekly\n \n 2021-12-16 11:08:33 UTC\n \n 2021-12-16 11:17: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 1393\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 13:08:33',4,'2021-12-16 13:17:21',4,0,NULL,NULL,NULL,'b78d514c-0203-44a4-8bc2-e04e521d3eff'),(1394,'CI57:VL Blood Draws in recent 3 months','CI57:VL Blood Draws recent 3 months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI57:VL Blood Draws in recent 3 months\n CI57:VL Blood Draws recent 3 months\n \n 2021-12-16 11:20:31 UTC\n \n 2021-12-16 11:22: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 1394\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 13:20:31',4,'2021-12-16 13:22:32',4,0,NULL,NULL,NULL,'db80bf53-873d-4c0c-8847-726847b0c417'),(1395,'CI58:VL Results received within 3 months','CI58:VL Results received within 3 months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI58:VL Results received within 3 months\n CI58:VL Results received within 3 months\n \n 2021-12-16 11:24:28 UTC\n \n 2021-12-16 11:25: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 1395\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 13:24:28',4,'2021-12-16 13:25:37',4,0,NULL,NULL,NULL,'5b8fbea7-884a-4e64-ae29-48732ba65c3a'),(1396,'CI59:VL Results received this month','CI59:VL Results received this month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI59:VL Results received this month\n CI59:VL Results received this month\n \n 2021-12-16 11:28:21 UTC\n \n 2021-12-16 11:29: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 1396\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 13:28:21',4,'2021-12-16 13:29:17',4,0,NULL,NULL,NULL,'019b40c1-d072-414e-9ffd-a6f00f6eab86'),(1397,'CI60:Pending Results within 3 months','CI60:Pending Results within 3 months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI60:Pending Results within 3 months\n CI60:Pending Results within 3 months\n \n 2021-12-16 12:02:36 UTC\n \n 2021-12-16 12:03: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 1397\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 14:02:36',4,'2021-12-16 14:03:44',4,0,NULL,NULL,NULL,'3f59f3a6-d116-4fce-ac20-e739c9cfefa6'),(1398,'CI61:Pending Results within 2 months','CI61:Pending Results within 2 months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI61:Pending Results within 2 months\n CI61:Pending Results within 2 months\n \n 2021-12-16 12:05:54 UTC\n \n 2021-12-16 12:06: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 1398\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 14:05:54',4,'2021-12-16 14:06:36',4,0,NULL,NULL,NULL,'a8dcaa40-a96f-4714-a161-c9493a75ba91'),(1399,'CI62:Pending Results within 1 month','CI62:Pending Results within 1 month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI62:Pending Results within 1 month\n CI62:Pending Results within 1 month\n \n 2021-12-16 12:07:27 UTC\n \n 2021-12-16 12:08: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 1399\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2021-12-16 14:07:27',4,'2021-12-16 14:08:04',4,0,NULL,NULL,NULL,'cb06df8b-0d0f-415c-ad52-322786e3e3fc'),(1401,'Discordant Couple','Couple discordant results','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Discordant Couple\n Couple discordant results\n \n 2022-02-16 18:59:38 UTC\n \n 2022-02-17 18:55: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 1401\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 \n (select o.person_id \n from obs o \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 \n patient_identifier.identifier_type IN (3,5) AND patient_identifier.preferred=1 \n \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n where concept_id in (4225) and value_coded in (2146) \n Group by o.person_id \n)\n','2022-02-17 00:29:38',4,'2022-02-18 00:25:55',4,0,NULL,NULL,NULL,'09606416-9fdb-404a-a23f-2670030a98c2'),(1402,'Indeterminate results','indeterminate and inconclusive test results','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Indeterminate results\n indeterminate and inconclusive test results\n \n 2022-02-17 03:45:12 UTC\n \n 2022-02-17 03:57: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 1402\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 \n (select o.person_id as Id \n from obs o \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 \n patient_identifier.identifier_type IN (3,5) AND patient_identifier.preferred=1 \n \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n where concept_id in (4223) and value_coded in (4220) \n Group by o.person_id)\n','2022-02-17 09:15:12',4,'2022-02-17 09:27:02',4,0,NULL,NULL,NULL,'91361707-3e26-4592-b606-0d5b76fed7f5'),(1403,'Couples Only','HTS Clients Tested as Couple','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Couples Only\n HTS Clients Tested as Couple\n \n 2022-02-17 03:58:23 UTC\n \n 2022-02-24 07: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 1403\n select distinct o.person_id \n from obs o inner join location l on o.location_id = l.location_id \n where (o.location_id =:location or parent_location =:location) \n and o.person_id in \n (select o.person_id \n from obs o \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 \n patient_identifier.identifier_type IN (3,5) AND patient_identifier.preferred=1 \n \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n where concept_id in (2166) and value_coded in (2146) \n Group by o.person_id)\n','2022-02-17 09:28:23',4,'2022-02-24 12:30:31',4,0,NULL,NULL,NULL,'7a60cfbe-7e8b-49bb-8f69-bf04e37c37e9'),(1404,'HTS Clients Screened ','Number of HTS Clients Screened for TB','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Clients Screened \n Number of HTS Clients Screened for TB\n \n 2022-02-17 04:07:32 UTC\n \n 2022-03-17 10:26: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 1404\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 \n (select o.person_id \n from obs o \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 \n patient_identifier.identifier_type IN (3) AND patient_identifier.preferred=1 \n \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n where concept_id in (2294) and value_coded in (2146) \n Group by o.person_id)\n','2022-02-17 04:07:32',4,'2022-03-17 10:26:05',4,0,NULL,NULL,NULL,'5a029d5e-f4ba-4e2c-8dc6-ba01d0ca45af'),(1405,'Confirmed Negative','HTS Confirmed Negative Clients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Confirmed Negative\n HTS Confirmed Negative Clients\n \n 2022-02-17 12:05:47 UTC\n \n 2022-02-17 12:14: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 1405\n select distinct o.person_id \n from obs o inner join location l on o.location_id = l.location_id \n where (o.location_id =:location or parent_location =:location) \n and o.person_id in \n (select o.person_id \n from obs o \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 \n patient_identifier.identifier_type IN (3,5) AND patient_identifier.preferred=1 \n \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n where concept_id in (2165) and value_coded in (1016) \n Group by o.person_id)\n','2022-02-17 17:35:47',4,'2022-02-17 17:44:51',4,0,NULL,NULL,NULL,'c9c50904-153c-4517-b462-5df83b4fd9b9'),(1406,'Confirmed Positives','HTS Confirmed Positive Clients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Confirmed Positives\n HTS Confirmed Positive Clients\n \n 2022-02-17 12:17:04 UTC\n \n 2022-02-17 12: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 1406\n select distinct o.person_id \n from obs o inner join location l on o.location_id = l.location_id \n where (o.location_id =:location or parent_location =:location) \n and o.person_id in \n (select o.person_id \n from obs o \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 \n patient_identifier.identifier_type IN (3,5) AND patient_identifier.preferred=1 \n \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n where concept_id in (2165) and value_coded in (1738) \n Group by o.person_id)\n','2022-02-17 17:47:04',4,'2022-02-17 17:49:20',4,0,NULL,NULL,NULL,'44a79d1e-c5ea-44ab-b6df-0c21abaa9a38'),(1407,'Indeterminate results','Total Indeterminate results','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.SqlIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Indeterminate results\n Total Indeterminate results\n \n 2022-02-17 17:40:50 UTC\n \n','2022-02-17 23:10:50',4,NULL,NULL,0,NULL,NULL,NULL,'13337249-1e1c-42a4-9f3e-edacbb906e5d'),(1408,'Indeterminate results','Total Indeterminate results','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Indeterminate results\n Total Indeterminate results\n \n 2022-02-17 17:42:25 UTC\n \n 2022-02-17 17: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 1408\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-02-17 23:12:25',4,'2022-02-17 23:16:50',4,0,NULL,NULL,NULL,'e4e5a5d1-5d70-4a2e-83fb-902c382967d5'),(1409,'HTS Screened','Number of HTS Clients screened for TB','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Screened\n Number of HTS Clients screened for TB\n \n 2022-02-17 17:49:05 UTC\n \n 2022-02-17 17:55: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 1409\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-02-17 23:19:05',4,'2022-02-17 23:25:54',4,0,NULL,NULL,NULL,'5abf9b9c-5225-4470-a455-bcc7ca6addca'),(1411,'HTS Clients Screened for TB Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Clients Screened for TB Data Set\n \n 2022-02-17 17:59:08 UTC\n \n 2022-02-17 18:30: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 1411\n \n \n DM_Sex\n \n \n \n \n \n \n \n \n HTS_Female\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 HTS_Males\n \n \n \n \n DM_Sex\n Males\n \n \n \n \n \n','2022-02-17 23:29:08',4,'2022-02-18 00:00:56',4,0,NULL,NULL,NULL,'86204394-0168-468b-b3d8-0de0beb04bc2'),(1412,'Couples Only','HTS Clients tested as couples','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Couples Only\n HTS Clients tested as couples\n \n 2022-02-17 18:39:17 UTC\n \n 2022-02-17 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 1412\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-02-18 00:09:17',4,'2022-02-18 00:11:37',4,0,NULL,NULL,NULL,'fa71acc6-bc29-4927-bbc4-d49906763b94'),(1413,'Discordant Results','Discordant Test Resultes','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Discordant Results\n Discordant Test Resultes\n \n 2022-02-17 18:53:30 UTC\n \n 2022-02-17 18:57: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 1413\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-02-18 00:23:30',4,'2022-02-18 00:27:04',4,0,NULL,NULL,NULL,'73ea8489-1fa9-46ab-a2ce-6b6b2d73a33e'),(1414,'Confirmed Negatives','Number of Confirmed Negative Results','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Confirmed Negatives\n Number of Confirmed Negative Results\n \n 2022-02-17 18:59:07 UTC\n \n 2022-02-17 19:05: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 1414\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-02-18 00:29:07',4,'2022-02-18 00:35:44',4,0,NULL,NULL,NULL,'e78ac003-c014-430b-806c-8f71e0b33164'),(1415,'Confirmed Positives','Number of confirmed positive results','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Confirmed Positives\n Number of confirmed positive results\n \n 2022-02-17 19:07:25 UTC\n \n 2022-02-17 19:08: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 1415\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-02-18 00:37:25',4,'2022-02-18 00:38:40',4,0,NULL,NULL,NULL,'c43780c6-a70b-4cca-9821-af8fac2e5b75'),(1417,'Total Indeterminate Results Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Total Indeterminate Results Data Set\n \n 2022-02-17 19:12:45 UTC\n \n 2022-02-17 19:19: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 1417\n \n \n \n \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','2022-02-18 00:42:45',4,'2022-02-18 00:49:17',4,0,NULL,NULL,NULL,'d8134c4d-7b2d-4421-93b5-986cf5263b17'),(1419,'Couples Only Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Couples Only Data Set\n \n 2022-02-17 19:22:38 UTC\n \n 2022-02-17 19:23: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 1419\n \n \n \n \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','2022-02-18 00:52:38',4,'2022-02-18 00:53:37',4,0,NULL,NULL,NULL,'5f221d24-9b0f-4b56-8659-2262fa6383ca'),(1421,'Discordant Test Results Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Discordant Test Results Data Set\n \n 2022-02-17 19:25:59 UTC\n \n 2022-02-17 19:26: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 1421\n \n \n \n \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','2022-02-18 00:55:59',4,'2022-02-18 00:56:57',4,0,NULL,NULL,NULL,'fe57a3d6-6ea3-4878-ab19-d3b2bc676b18'),(1422,'HTS_Post_Test_Counseling','HTS_Post_Test_Counseling','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS_Post_Test_Counseling\n HTS_Post_Test_Counseling\n \n 2022-02-17 19:30:06 UTC\n \n 2022-02-17 19:54: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 1422\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','2022-02-18 01:00:06',4,'2022-02-18 01:24:15',4,0,NULL,NULL,NULL,'a37e3f91-87d6-4126-b164-4888fa187f93'),(1423,'Number of Confirmatory Test Results Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Number of Confirmatory Test Results Data Set\n \n 2022-02-17 19:30:22 UTC\n \n 2022-02-24 18:31: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 1423\n \n \n DM_Sex\n \n \n \n \n \n \n \n \n Couples\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 Distri_Kit\n \n \n \n \n \n \n \n \n \n HTS_Female\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n \n \n \n HTS_Males\n \n \n \n \n DM_Sex\n Males\n \n \n \n \n \n Ind_Res\n \n \n \n \n \n \n \n \n \n Retur_Kits\n \n \n \n \n \n \n \n \n \n con_neg\n \n \n \n \n \n \n \n \n \n con_pos\n \n \n \n \n \n \n \n \n \n disc_res\n \n \n \n \n \n \n \n \n \n','2022-02-18 01:00:22',4,'2022-02-25 00:01:20',4,0,NULL,NULL,NULL,'e3eaeee4-8afa-4090-a2c5-72662d743f68'),(1425,'Distributed Self test Kits','Total HTS Self Test Distributed Kits','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Distributed Self test Kits\n Total HTS Self Test Distributed Kits\n \n 2022-02-24 13:03:04 UTC\n \n 2024-01-31 15:47: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 1425\n select distinct o.obs_id \n from obs o \n where o.obs_id in ( \n select o.person_id \n from obs o \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 \n patient_identifier.identifier_type IN (3,5) AND patient_identifier.preferred=1 \n INNER JOIN location l on o.location_id = l.location_id and l.retired=0 \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n where concept_id in (4968) \n and (o.location_id = :location or parent_location = :location) \n Union All \n select o.person_id \n from obs o \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 \n patient_identifier.identifier_type IN (3,5) AND patient_identifier.preferred=1 \n INNER JOIN location l on o.location_id = l.location_id and l.retired=0 \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n where concept_id in (4845) and value_coded in (4822) \n and (o.location_id = :location or parent_location = :location) \n )\n','2022-02-24 18:33:04',4,'2024-01-31 21:17:34',4,0,NULL,NULL,NULL,'7fb1f754-6cb8-4d98-bbeb-49a931f97994'),(1426,'Distributed Self Test Kits','Total Distributed Self Test Kits','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Distributed Self Test Kits\n Total Distributed Self Test Kits\n \n 2022-02-24 13:33:06 UTC\n \n 2022-02-24 18:11: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 1426\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-02-24 19:03:06',4,'2022-02-24 23:41:54',4,0,NULL,NULL,NULL,'45e24163-6e6a-44a8-a168-1960f92e6664'),(1427,'HTS Self Test Kits Returned','Total HTS Self Test Kits Returned','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Self Test Kits Returned\n Total HTS Self Test Kits Returned\n \n 2022-02-24 18:14:58 UTC\n \n 2022-02-24 18:25: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 1427\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-02-24 23:44:58',4,'2022-02-24 23:55:27',4,0,NULL,NULL,NULL,'e448334c-d0c9-46cd-8041-45a9492aecb7'),(1428,'Returned Self Test Kits','Total Returned Self Test Kits','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Returned Self Test Kits\n Total Returned Self Test Kits\n \n 2022-02-24 18:19:33 UTC\n \n 2024-01-31 15:51: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 1428\n select distinct o.obs_id \n from obs o \n where o.obs_id in ( \n select o.person_id \n from obs o \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 \n patient_identifier.identifier_type IN (3,5) AND patient_identifier.preferred=1 \n INNER JOIN location l on o.location_id = l.location_id and l.retired=0 \n AND o.voided=0 \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n \n where concept_id in (4844) and value_coded not in (2148) \n and (o.location_id = :location or parent_location = :location) \n Group by o.person_id \n )\n','2022-02-24 23:49:33',4,'2024-01-31 21:21:23',4,0,NULL,NULL,NULL,'fbebdef1-7e03-4061-b525-95f86632ab49'),(1429,'ART Clients Stopped','ART Clients who stopped treatment in that month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART Clients Stopped\n ART Clients who stopped treatment in that month\n \n 2022-04-28 08:52:48 UTC\n \n 2022-04-28 08:54: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 1429\n select os.person_id \n from obs os \n inner join location l on os.location_id = l.location_id \n where os.concept_id = 3701 and os.voided = 0 \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.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3767 and o.value_coded = 2297 \n and o.voided = 0 \n \n )\n','2022-04-28 08:52:48',4,'2022-04-28 08:54:53',4,0,NULL,NULL,NULL,'2ea61d1f-e032-452e-bc0c-5ffb80c1a256'),(1430,'Clients given 4L weighing 0-3.9kg','Clients given 4L weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 0-3.9kg\n Clients given 4L weighing 0-3.9kg\n \n 2022-06-30 09:34:15 UTC\n \n 2023-08-03 10:37: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 1430\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:34:15',4,'2023-08-03 12:37:31',4,0,NULL,NULL,NULL,'1cbd9712-0dde-45fa-977c-98e3fd65681b'),(1431,'Clients given 4C weighing 0-3.9kg','Clients given 4C weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 0-3.9kg\n Clients given 4C weighing 0-3.9kg\n \n 2022-06-30 09:37:12 UTC\n \n 2023-07-27 10:09: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 1431\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:37:12',4,'2023-07-27 12:09:00',4,0,NULL,NULL,NULL,'9cd0146e-b566-4e02-9d37-da46810c833e'),(1432,'Clients given 4L weighing 4-5.9kg','Clients given 4L weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 4-5.9kg\n Clients given 4L weighing 4-5.9kg\n \n 2022-06-30 09:37:43 UTC\n \n 2023-08-03 10:43: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 1432\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:37:43',4,'2023-08-03 12:43:41',4,0,NULL,NULL,NULL,'aecca82d-d3c2-429d-acb2-56e1657ce6db'),(1433,'Clients given 4L weighing 6-9.9kg','Clients given 4L weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 6-9.9kg\n Clients given 4L weighing 6-9.9kg\n \n 2022-06-30 09:39:53 UTC\n \n 2023-08-03 10:44: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 1433\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:39:53',4,'2023-08-03 12:44:44',4,0,NULL,NULL,NULL,'1758b50a-2a2c-4b2c-b795-355255878304'),(1434,'Clients given 4L weighing 10-13.9kg','Clients given 4L weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 10-13.9kg\n Clients given 4L weighing 10-13.9kg\n \n 2022-06-30 09:42:34 UTC\n \n 2023-08-03 10:40: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 1434\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:42:34',4,'2023-08-03 12:40:14',4,0,NULL,NULL,NULL,'2c470abf-a5dc-4c5e-a1f0-dc85cc66b111'); +INSERT INTO `serialized_object` VALUES (1435,'Clients given 4C weighing 4-5.9kg','Clients given 4C weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 4-5.9kg\n Clients given 4C weighing 4-5.9kg\n \n 2022-06-30 09:43:58 UTC\n \n 2023-07-27 10:06: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 1435\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:43:58',4,'2023-07-27 12:06:25',4,0,NULL,NULL,NULL,'ae72a1f2-5b35-4736-8a3d-d09eeaafaaf1'),(1436,'Clients given 4L weighing 14-19.9kg','Clients given 4L weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 14-19.9kg\n Clients given 4L weighing 14-19.9kg\n \n 2022-06-30 09:44:49 UTC\n \n 2023-08-03 10:41: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 1436\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:44:49',4,'2023-08-03 12:41:10',4,0,NULL,NULL,NULL,'c0c8885b-814c-4cb2-8c23-c10871a2b76d'),(1437,'Clients given 4L weighing 20-24.9kg','Clients given 4L weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 20-24.9kg\n Clients given 4L weighing 20-24.9kg\n \n 2022-06-30 09:45:58 UTC\n \n 2023-08-03 10:41: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 1437\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 \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 \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 (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','2022-06-30 11:45:58',4,'2023-08-03 12:41:51',4,0,NULL,NULL,NULL,'889cb817-6500-4ae1-9f84-e1ec42b46c00'),(1438,'Clients given 4L weighing 25-34.9kg','Clients given 4L weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 25-34.9kg\n Clients given 4L weighing 25-34.9kg\n \n 2022-06-30 09:47:36 UTC\n \n 2023-08-03 10:42: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 1438\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:47:36',4,'2023-08-03 12:42:36',4,0,NULL,NULL,NULL,'51076831-4759-4f7d-8d57-47fb8862e61c'),(1439,'Clients given 4L weighing >=35','Clients given 4L weighing >=35','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing >=35\n Clients given 4L weighing >=35\n \n 2022-06-30 09:48:54 UTC\n \n 2023-08-03 10:36: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 1439\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:48:54',4,'2023-08-03 12:36:25',4,0,NULL,NULL,NULL,'3ba57d29-931d-454e-916c-9e0c0e90d805'),(1440,'Clients given 4C weighing 6-9.9kg','Clients given 4C weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 6-9.9kg\n Clients given 4C weighing 6-9.9kg\n \n 2022-06-30 09:49:04 UTC\n \n 2023-07-27 10:06: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 1440\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:49:04',4,'2023-07-27 12:06:55',4,0,NULL,NULL,NULL,'d3d16a07-4319-4d63-82a2-4f47f7928a00'),(1441,'Clients given 4C weighing 10-13.9kg','Clients given 4C weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 10-13.9kg\n Clients given 4C weighing 10-13.9kg\n \n 2022-06-30 09:50:51 UTC\n \n 2023-07-27 10:01: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 1441\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:50:51',4,'2023-07-27 12:01:01',4,0,NULL,NULL,NULL,'09622f4b-49d5-4214-9eb4-7de4cae57a9d'),(1442,'Clients given 4K weighing 0-3.9kg','Clients given 4K weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 0-3.9kg\n Clients given 4K weighing 0-3.9kg\n \n 2022-06-30 09:52:14 UTC\n \n 2023-07-27 12:56: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 1442\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:52:14',4,'2023-07-27 14:56:47',4,0,NULL,NULL,NULL,'0f76ed94-e4f8-4f94-9bc4-4adbba1c66c1'),(1443,'Clients given 4C weighing 14-19.9kg','Clients given 4C weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 14-19.9kg\n Clients given 4C weighing 14-19.9kg\n \n 2022-06-30 09:53:51 UTC\n \n 2023-08-15 13:35: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 1443\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:53:51',4,'2023-08-15 15:35:14',4,0,NULL,NULL,NULL,'034244be-ee9b-4c5f-9c05-b69eefad3051'),(1444,'Clients given 4K weighing 4-5.9kg','Clients given 4K weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 4-5.9kg\n Clients given 4K weighing 4-5.9kg\n \n 2022-06-30 09:53:56 UTC\n \n 2023-07-27 12:58: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 1444\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:53:56',4,'2023-07-27 14:58:37',4,0,NULL,NULL,NULL,'fe700a2f-6c6b-4ab5-8692-4171cb0dc27c'),(1445,'Clients given 4K weighing 6-9.9kg','Clients given 4K weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 6-9.9kg\n Clients given 4K weighing 6-9.9kg\n \n 2022-06-30 09:55:49 UTC\n \n 2023-07-27 12:59: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 1445\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:55:49',4,'2023-07-27 14:59:00',4,0,NULL,NULL,NULL,'db5d6766-3a33-43c4-9732-a4d83ce9b1ea'),(1446,'Clients given 4K weighing 10-13.9kg','Clients given 4K weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 10-13.9kg\n Clients given 4K weighing 10-13.9kg\n \n 2022-06-30 09:56:49 UTC\n \n 2023-07-27 12:57: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 1446\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:56:49',4,'2023-07-27 14:57:10',4,0,NULL,NULL,NULL,'494aa500-1c2d-45b2-b6ba-aa987b52622a'),(1447,'Clients given 4K weighing 14-19.9kg','Clients given 4K weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 14-19.9kg\n Clients given 4K weighing 14-19.9kg\n \n 2022-06-30 09:58:26 UTC\n \n 2023-07-27 12:57: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 1447\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 11:58:26',4,'2023-07-27 14:57:30',4,0,NULL,NULL,NULL,'480ac769-5b88-4485-8885-03322fa49fc8'),(1448,'Clients given 4K weighing 20-24.9kg','Clients given 4K weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 20-24.9kg\n Clients given 4K weighing 20-24.9kg\n \n 2022-06-30 09:59:23 UTC\n \n 2023-07-27 12:57: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 1448\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 \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 \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 (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','2022-06-30 11:59:23',4,'2023-07-27 14:57:51',4,0,NULL,NULL,NULL,'3bd2b9e5-01e8-43ac-a17a-3912a89d7ff1'),(1449,'Clients given 4K weighing 25-34.9kg','Clients given 4K weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 25-34.9kg\n Clients given 4K weighing 25-34.9kg\n \n 2022-06-30 10:01:21 UTC\n \n 2023-07-27 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 1449\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:01:21',4,'2023-07-27 14:58:15',4,0,NULL,NULL,NULL,'921f9499-c27b-4b41-95e0-b85292fa2f92'),(1450,'Clients given 4K weighing >=35kg','Clients given 4K weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing >=35kg\n Clients given 4K weighing >=35kg\n \n 2022-06-30 10:02:42 UTC\n \n 2023-07-27 12:56: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 1450\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:02:42',4,'2023-07-27 14:56:23',4,0,NULL,NULL,NULL,'3229cff2-e047-4073-90c1-e06e867b402b'),(1451,'Clients given 4C weighing 20-24.9kg','Clients given 4C weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 20-24.9kg\n Clients given 4C weighing 20-24.9kg\n \n 2022-06-30 10:02:57 UTC\n \n 2023-07-27 10:03: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 1451\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 \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 \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 (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','2022-06-30 12:02:57',4,'2023-07-27 12:03:19',4,0,NULL,NULL,NULL,'9e67fab4-3382-49c7-bc4a-8e6f95ecd7ff'),(1452,'Clients given 4C weighing 25-34.9kg','Clients given 4C weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 25-34.9kg\n Clients given 4C weighing 25-34.9kg\n \n 2022-06-30 10:04:55 UTC\n \n 2023-07-27 10:05: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 1452\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:04:55',4,'2023-07-27 12:05:26',4,0,NULL,NULL,NULL,'1e41db8d-aca6-471d-af67-bddf792eb12e'),(1453,'Clients given 4C weighing >=35kg','Clients given 4C weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing >=35kg\n Clients given 4C weighing >=35kg\n \n 2022-06-30 10:06:32 UTC\n \n 2023-07-27 10:08: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 1453\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:06:32',4,'2023-07-27 12:08:27',4,0,NULL,NULL,NULL,'9bb26987-59cb-48b8-8235-502a3d2f52b4'),(1454,'Clients given 4J weighing 0-3.9kg','Clients given 4J weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 0-3.9kg\n Clients given 4J weighing 0-3.9kg\n \n 2022-06-30 10:07:54 UTC\n \n 2023-07-27 10:59: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 1454\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:07:54',4,'2023-07-27 12:59:20',4,0,NULL,NULL,NULL,'b4265cc6-ac60-4aeb-ba91-ef213a6d949e'),(1455,'Clients given 4D weighing 0-3.9kg','Clients given 4D weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 0-3.9kg\n Clients given 4D weighing 0-3.9kg\n \n 2022-06-30 10:08:47 UTC\n \n 2023-07-27 09:27:03 UTC\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 endDate\n \n java.util.Date\n true\n \n \n 1455\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 \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 \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 (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 > 0 and _weight <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:08:47',4,'2023-07-27 11:27:03',4,0,NULL,NULL,NULL,'d998e2f6-840d-473b-b176-e0550de42412'),(1456,'Clients given 4D weighing 4-5.9kg','Clients given 4D weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 4-5.9kg\n Clients given 4D weighing 4-5.9kg\n \n 2022-06-30 10:13:16 UTC\n \n 2023-07-27 09:38: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 1456\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 \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 \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 (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 >= 4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:13:16',4,'2023-07-27 11:38:34',4,0,NULL,NULL,NULL,'6a8a13fc-28a2-4778-840f-e45fb90009b6'),(1457,'Clients given 4D weighing 6-9.9kg','Clients given 4D weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 6-9.9kg\n Clients given 4D weighing 6-9.9kg\n \n 2022-06-30 10:15:03 UTC\n \n 2023-07-27 09:39: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 1457\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 \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 \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 (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 >= 6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:15:03',4,'2023-07-27 11:39:10',4,0,NULL,NULL,NULL,'5d76364b-1150-4bd7-b456-7844b2f28312'),(1458,'Clients given 4J weighing 4-5.9kg','Clients given 4J weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 4-5.9kg\n Clients given 4J weighing 4-5.9kg\n \n 2022-06-30 10:15:44 UTC\n \n 2023-07-27 11:01: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 1458\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:15:44',4,'2023-07-27 13:01:23',4,0,NULL,NULL,NULL,'8a4200ea-3da7-406f-9961-272c3898fe6c'),(1459,'Clients given 4D weighing 10-13.9kg','Clients given 4D weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 10-13.9kg\n Clients given 4D weighing 10-13.9kg\n \n 2022-06-30 10:18:04 UTC\n \n 2023-07-27 09:28: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 1459\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 \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 \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 (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 >= 10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:18:04',4,'2023-07-27 11:28:41',4,0,NULL,NULL,NULL,'8a6e7ee5-2a61-4944-bfb4-bb47a5698f6c'),(1460,'Clients given 4D weighing 14-19.9kg','Clients given 4D weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 14-19.9kg\n Clients given 4D weighing 14-19.9kg\n \n 2022-06-30 10:19:54 UTC\n \n 2023-07-27 09:36: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 1460\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 \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 \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 (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 >= 14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:19:54',4,'2023-07-27 11:36:07',4,0,NULL,NULL,NULL,'45092d9a-31f7-4734-bad7-6afa4af47c8c'),(1461,'Clients given 4J weighing 6-9.9kg','Clients given 4J weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 6-9.9kg\n Clients given 4J weighing 6-9.9kg\n \n 2022-06-30 10:21:51 UTC\n \n 2023-07-27 11:01: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 1461\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:21:51',4,'2023-07-27 13:01:41',4,0,NULL,NULL,NULL,'5f5b772e-63e5-4b96-b211-629491f33c0d'),(1462,'Clients given 4D weighing 20-24.9kg','Clients given 4D weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 20-24.9kg\n Clients given 4D weighing 20-24.9kg\n \n 2022-06-30 10:22:05 UTC\n \n 2023-07-27 09: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 1462\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 \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 \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 (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','2022-06-30 12:22:05',4,'2023-07-27 11:36:30',4,0,NULL,NULL,NULL,'a0d8e3b8-722d-491c-bd0f-fa90956f51db'),(1463,'Clients given 4J weighing 10-13.9kg','Clients given 4J weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 10-13.9kg\n Clients given 4J weighing 10-13.9kg\n \n 2022-06-30 10:22:53 UTC\n \n 2023-07-27 10:59: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 1463\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:22:53',4,'2023-07-27 12:59:41',4,0,NULL,NULL,NULL,'790715b6-630c-4294-8577-6f4815e44797'),(1464,'Clients given 4J weighing 14-19.9kg','Clients given 4J weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 14-19.9kg\n Clients given 4J weighing 14-19.9kg\n \n 2022-06-30 10:24:03 UTC\n \n 2023-07-27 10:59: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 1464\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:24:03',4,'2023-07-27 12:59:55',4,0,NULL,NULL,NULL,'08528ef7-fb50-42e0-b520-afb3ecedbad2'),(1465,'Clients given 4D weighing 25-34.9kg','Clients given 4D weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 25-34.9kg\n Clients given 4D weighing 25-34.9kg\n \n 2022-06-30 10:24:49 UTC\n \n 2023-07-27 09:37: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 1465\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 \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 \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 (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 >= 25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:24:49',4,'2023-07-27 11:37:45',4,0,NULL,NULL,NULL,'527ab6b7-03a7-4ad5-86ae-2c494b0b3cb0'),(1466,'Clients given 4J weighing 20-24.9kg','Clients given 4J weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 20-24.9kg\n Clients given 4J weighing 20-24.9kg\n \n 2022-06-30 10:24:52 UTC\n \n 2023-07-27 11: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 1466\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 \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 \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 (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','2022-06-30 12:24:52',4,'2023-07-27 13:00:42',4,0,NULL,NULL,NULL,'65757623-b703-423a-a092-06e04ed87180'),(1467,'Clients given 4D weighing >= 35kg','Clients given 4D weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing >= 35kg\n Clients given 4D weighing >= 35kg\n \n 2022-06-30 10:27:51 UTC\n \n 2023-07-27 09:40: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 1467\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 \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 \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 (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 >= 35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:27:51',4,'2023-07-27 11:40:28',4,0,NULL,NULL,NULL,'242cded5-b463-489d-a941-901a590d1d47'),(1468,'Clients given 4J weighing 25-34.9kg','Clients given 4J weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 25-34.9kg\n Clients given 4J weighing 25-34.9kg\n \n 2022-06-30 10:28:09 UTC\n \n 2023-07-27 11:01: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 1468\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:28:09',4,'2023-07-27 13:01:04',4,0,NULL,NULL,NULL,'83bc989a-e2b7-4bed-a628-fc59a59c1ba6'),(1469,'Clients given 4J weighing >=35kg','Clients given 4J weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing >=35kg\n Clients given 4J weighing >=35kg\n \n 2022-06-30 10:28:53 UTC\n \n 2023-07-27 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 1469\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:28:53',4,'2023-07-27 12:58:41',4,0,NULL,NULL,NULL,'72f98838-eb15-4cb6-a914-0852726e5647'),(1470,'Clients given 4E weighing 0-3.9kg','Clients given 4E weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 0-3.9kg\n Clients given 4E weighing 0-3.9kg\n \n 2022-06-30 10:29:43 UTC\n \n 2023-07-27 10:22: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 1470\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:29:43',4,'2023-07-27 12:22:02',4,0,NULL,NULL,NULL,'0ab11624-0249-40a0-971b-e3e8bb23ea70'),(1471,'Clients given 4E weighing 4-5.9kg','Clients given 4E weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 4-5.9kg\n Clients given 4E weighing 4-5.9kg\n \n 2022-06-30 10:33:36 UTC\n \n 2023-07-27 10:26: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 1471\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:33:36',4,'2023-07-27 12:26:59',4,0,NULL,NULL,NULL,'8519fd1c-bd73-43d6-8c51-e76191131ca3'),(1472,'Clients given 4E weighing 6-9.9kg','Clients given 4E weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 6-9.9kg\n Clients given 4E weighing 6-9.9kg\n \n 2022-06-30 10:35:26 UTC\n \n 2023-07-27 10:27: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 1472\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:35:26',4,'2023-07-27 12:27:56',4,0,NULL,NULL,NULL,'c165720f-b024-49dc-8775-49de3830ea6f'),(1473,'Clients given 4E weighing 10-13.9kg','Clients given 4E weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 10-13.9kg\n Clients given 4E weighing 10-13.9kg\n \n 2022-06-30 10:36:35 UTC\n \n 2023-07-27 10:22: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 java.lang.String\n true\n \n \n 1473\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:36:35',4,'2023-07-27 12:22:52',4,0,NULL,NULL,NULL,'c14db25f-8596-4fae-ab12-430a740aa487'),(1474,'Clients given 4E weighing 14-19.9kg','Clients given 4E weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 14-19.9kg\n Clients given 4E weighing 14-19.9kg\n \n 2022-06-30 10:38:12 UTC\n \n 2023-07-27 10:24: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 1474\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:38:12',4,'2023-07-27 12:24:17',4,0,NULL,NULL,NULL,'bc5dc540-6696-47aa-a512-1cb7a78d7377'),(1475,'Clients given 4E weighing 20-24.9kg','Clients given 4E weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 20-24.9kg\n Clients given 4E weighing 20-24.9kg\n \n 2022-06-30 10:40:04 UTC\n \n 2023-07-27 10:25: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 1475\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 \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 \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 (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','2022-06-30 12:40:04',4,'2023-07-27 12:25:54',4,0,NULL,NULL,NULL,'221244d7-0042-432a-a711-d9cccd4358ab'),(1476,'Clients given 4E weighing 25-34.9kg','Clients given 4E weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 25-34.9kg\n Clients given 4E weighing 25-34.9kg\n \n 2022-06-30 10:41:40 UTC\n \n 2023-07-27 10: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 1476\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:41:40',4,'2023-07-27 12:26:28',4,0,NULL,NULL,NULL,'9490638d-1289-4114-bbbc-724006e38d93'),(1477,'Clients given 4E weighing >= 35kg','Clients given 4E weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing >= 35kg\n Clients given 4E weighing >= 35kg\n \n 2022-06-30 10:43:04 UTC\n \n 2023-07-27 10:21: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 1477\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:43:04',4,'2023-07-27 12:21:29',4,0,NULL,NULL,NULL,'2bf8b315-8095-4176-ab7c-34d32e5302bb'),(1478,'Clients given 4F weighing 0-3.9kg','Clients given 4F weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 0-3.9kg\n Clients given 4F weighing 0-3.9kg\n \n 2022-06-30 10:44:22 UTC\n \n 2023-07-27 10:41: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 1478\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:44:22',4,'2023-07-27 12:41:29',4,0,NULL,NULL,NULL,'42b80ebc-ab48-48ca-a4f4-a20229c3e624'),(1479,'Clients given 4H weighing 0-3.9kg','Clients given 4H weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 0-3.9kg\n Clients given 4H weighing 0-3.9kg\n \n 2022-06-30 10:44:56 UTC\n \n 2023-07-27 10:55: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 1479\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:44:56',4,'2023-07-27 12:55:00',4,0,NULL,NULL,NULL,'4d8d584e-acb2-4935-b2ba-b1b175d8f7d5'),(1480,'Clients given 4H weighing 4-5.9kg','Clients given 4H weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 4-5.9kg\n Clients given 4H weighing 4-5.9kg\n \n 2022-06-30 10:46:13 UTC\n \n 2023-07-27 10:56: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 1480\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:46:13',4,'2023-07-27 12:56:53',4,0,NULL,NULL,NULL,'26f845a2-246d-468b-817a-9c60bdd078b9'),(1481,'Clients given 4F weighing 4-5.9kg','Clients given 4F weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 4-5.9kg\n Clients given 4F weighing 4-5.9kg\n \n 2022-06-30 10:46:29 UTC\n \n 2023-07-27 10:43: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 1481\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:46:29',4,'2023-07-27 12:43:41',4,0,NULL,NULL,NULL,'72862b43-6e4e-4a10-822f-ac5648433215'),(1482,'Clients given 4H weighing 6-9.9kg','Clients given 4H weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 6-9.9kg\n Clients given 4H weighing 6-9.9kg\n \n 2022-06-30 10:46:57 UTC\n \n 2023-07-27 10:57: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 1482\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:46:57',4,'2023-07-27 12:57:16',4,0,NULL,NULL,NULL,'01c48121-50df-46cb-8a3b-35623d584ebf'),(1483,'Clients given 4H weighing 10-13.9kg','Clients given 4H weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 10-13.9kg\n Clients given 4H weighing 10-13.9kg\n \n 2022-06-30 10:47:36 UTC\n \n 2023-07-27 10:55: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 1483\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:47:36',4,'2023-07-27 12:55:36',4,0,NULL,NULL,NULL,'d02359fe-619b-4a9c-871b-ae3aa3a98aa2'),(1484,'Clients given 4F weighing 6-9.9kg','Clients given 4F weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 6-9.9kg\n Clients given 4F weighing 6-9.9kg\n \n 2022-06-30 10:47:39 UTC\n \n 2023-07-27 10:44: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 1484\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:47:39',4,'2023-07-27 12:44:02',4,0,NULL,NULL,NULL,'b67ded87-6d0d-4d6a-8d86-01fffedfca86'),(1485,'Clients given 4F weighing 10-13.9kg','Clients given 4F weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 10-13.9kg\n Clients given 4F weighing 10-13.9kg\n \n 2022-06-30 10:48:47 UTC\n \n 2023-07-27 10:41: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 1485\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:48:47',4,'2023-07-27 12:41:53',4,0,NULL,NULL,NULL,'9ff30aca-0d8d-4fca-a3a9-13c0f28c48ac'),(1486,'Clients given 4H weighing 14-19.9kg','Clients given 4H weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 14-19.9kg\n Clients given 4H weighing 14-19.9kg\n \n 2022-06-30 10:48:50 UTC\n \n 2023-07-27 10:55: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 1486\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:48:50',4,'2023-07-27 12:55:55',4,0,NULL,NULL,NULL,'4477b341-8fb3-4d94-bc1a-cec68c45d5e8'),(1487,'Clients given 4F weighing 14-19.9kg','Clients given 4F weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 14-19.9kg\n Clients given 4F weighing 14-19.9kg\n \n 2022-06-30 10:49:43 UTC\n \n 2023-07-27 10:42: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 1487\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:49:43',4,'2023-07-27 12:42:09',4,0,NULL,NULL,NULL,'bc68c0e3-f9af-458a-9c48-e498e27e55cf'),(1488,'Clients given 4H weighing 20-24.9kg','Clients given 4H weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 20-24.9kg\n Clients given 4H weighing 20-24.9kg\n \n 2022-06-30 10:49:44 UTC\n \n 2023-07-27 10:56: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 1488\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 \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 \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 (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','2022-06-30 12:49:44',4,'2023-07-27 12:56:17',4,0,NULL,NULL,NULL,'db7df0b0-048e-4292-8047-aede481f516a'),(1489,'Clients given 4H weighing 25-34.9kg','Clients given 4H weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 25-34.9kg\n Clients given 4H weighing 25-34.9kg\n \n 2022-06-30 10:50:30 UTC\n \n 2023-07-27 10:56: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 1489\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:50:30',4,'2023-07-27 12:56:36',4,0,NULL,NULL,NULL,'8a0ffc3a-6f13-41d4-9012-80f7df387328'),(1490,'Clients given 4F weighing 20-24.9kg','Clients given 4F weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 20-24.9kg\n Clients given 4F weighing 20-24.9kg\n \n 2022-06-30 10:50:41 UTC\n \n 2023-07-27 10:42: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 1490\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 \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 \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 (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','2022-06-30 12:50:41',4,'2023-07-27 12:42:33',4,0,NULL,NULL,NULL,'acf07216-1652-4e83-9d65-6823c59981a8'),(1491,'Clients given 4H weighing >=35kg','Clients given 4H weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing >=35kg\n Clients given 4H weighing >=35kg\n \n 2022-06-30 10:51:17 UTC\n \n 2023-07-27 10:54: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 1491\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:51:17',4,'2023-07-27 12:54:12',4,0,NULL,NULL,NULL,'831a76ea-3a0d-4c8c-b68f-fcb26f67f6d8'),(1492,'Clients given 4F weighing 25-34.9kg','Clients given 4F weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 25-34.9kg\n Clients given 4F weighing 25-34.9kg\n \n 2022-06-30 10:51:46 UTC\n \n 2023-07-27 10:43: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 1492\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:51:46',4,'2023-07-27 12:43:13',4,0,NULL,NULL,NULL,'3da33639-d791-4633-8e15-b41313cb55f1'),(1493,'Clients given 4F weighing >= 35kg','Clients given 4F weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing >= 35kg\n Clients given 4F weighing >= 35kg\n \n 2022-06-30 10:53:56 UTC\n \n 2023-07-27 10:40: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 1493\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:53:56',4,'2023-07-27 12:40:58',4,0,NULL,NULL,NULL,'c7599281-45dd-4b73-8ab0-ea8e524b98d1'),(1494,'Clients given 4G weighing 0-3.9kg','Clients given 4G weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 0-3.9kg\n Clients given 4G weighing 0-3.9kg\n \n 2022-06-30 10:54:05 UTC\n \n 2023-07-27 10:46: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 1494\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:54:05',4,'2023-07-27 12:46:39',4,0,NULL,NULL,NULL,'2475b103-3fa8-4b29-bb87-fab00aa27257'),(1495,'Clients given 4G weighing 4-5.9kg','Clients given 4G weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 4-5.9kg\n Clients given 4G weighing 4-5.9kg\n \n 2022-06-30 10:55:47 UTC\n \n 2023-07-27 10:48: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 1495\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:55:47',4,'2023-07-27 12:48:33',4,0,NULL,NULL,NULL,'b7fef4f2-1d0c-4942-88e3-45c9535ef4bc'),(1496,'Clients given 4G weighing 6-9.9kg','Clients given 4G weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 6-9.9kg\n Clients given 4G weighing 6-9.9kg\n \n 2022-06-30 10:56:50 UTC\n \n 2023-07-27 10:48: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 1496\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:56:50',4,'2023-07-27 12:48:51',4,0,NULL,NULL,NULL,'2539084a-3b56-4fd2-b7b7-1d75b7403e4c'),(1497,'Clients given 4G weighing 10-13.9kg','Clients given 4G weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 10-13.9kg\n Clients given 4G weighing 10-13.9kg\n \n 2022-06-30 10:57:46 UTC\n \n 2023-07-27 10:47: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 1497\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:57:46',4,'2023-07-27 12:47:08',4,0,NULL,NULL,NULL,'f7e13045-87fd-45c5-9e4c-818fbcb84888'),(1498,'Clients given 5A weighing 0-3.9kg','Clients given 5A weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 0-3.9kg\n Clients given 5A weighing 0-3.9kg\n \n 2022-06-30 10:58:03 UTC\n \n 2023-08-15 09:30: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 1498\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 \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 \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 (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>=0 and _weight <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:58:03',4,'2023-08-15 11:30:27',4,0,NULL,NULL,NULL,'87a82695-8e84-4f45-9b37-6fcfbdd68b9b'),(1499,'Clients given 4G weighing 14-19.9kg','Clients given 4G weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 14-19.9kg\n Clients given 4G weighing 14-19.9kg\n \n 2022-06-30 10:58:40 UTC\n \n 2023-07-27 10:47: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 1499\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 12:58:40',4,'2023-07-27 12:47:25',4,0,NULL,NULL,NULL,'91726710-94cf-4118-9c47-766cb5f11ae8'),(1500,'Clients given 4G weighing 20-24.9kg','Clients given 4G weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 20-24.9kg\n Clients given 4G weighing 20-24.9kg\n \n 2022-06-30 10:59:29 UTC\n \n 2023-07-27 10:47: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 1500\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 \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 \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 (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','2022-06-30 12:59:29',4,'2023-07-27 12:47:44',4,0,NULL,NULL,NULL,'e1070366-40ee-4f52-ae16-34a5de911a65'),(1501,'Clients given 4G weighing 25-34.9kg','Clients given 4G weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 25-34.9kg\n Clients given 4G weighing 25-34.9kg\n \n 2022-06-30 11:00:09 UTC\n \n 2023-07-27 10:48: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 1501\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:00:09',4,'2023-07-27 12:48:09',4,0,NULL,NULL,NULL,'d95d19d8-05d8-49d2-8b48-e0e179a7d99f'),(1502,'Clients given 5A weighing 4-5.9kg','Clients given 5A weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 4-5.9kg\n Clients given 5A weighing 4-5.9kg\n \n 2022-06-30 11:00:22 UTC\n \n 2023-08-15 10:10: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 1502\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:00:22',4,'2023-08-15 12:10:02',4,0,NULL,NULL,NULL,'5b216507-efb0-46a6-a948-08f4bc7a2bf2'),(1503,'Clients given 4G weighing >=35kg','Clients given 4G weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing >=35kg\n Clients given 4G weighing >=35kg\n \n 2022-06-30 11:00:59 UTC\n \n 2023-07-27 10:46: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 1503\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:00:59',4,'2023-07-27 12:46:14',4,0,NULL,NULL,NULL,'0aa0cdb4-feed-4504-ad23-50fdfbb94347'),(1504,'Clients given 5A weighing 6-9.9kg','Clients given 5A weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 6-9.9kg\n Clients given 5A weighing 6-9.9kg\n \n 2022-06-30 11:01:39 UTC\n \n 2022-06-30 11:02: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 1504\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:01:39',4,'2022-06-30 13:02:04',4,0,NULL,NULL,NULL,'8c1a3939-af3e-4859-bc97-cfb2a9d2e712'),(1505,'Clients given 5A weighing 10-13.9kg','Clients given 5A weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 10-13.9kg\n Clients given 5A weighing 10-13.9kg\n \n 2022-06-30 11:02:41 UTC\n \n 2023-08-15 09:38: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 1505\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:02:41',4,'2023-08-15 11:38:33',4,0,NULL,NULL,NULL,'3f90eaa0-49f7-4c6b-8ef4-9d75b1e83139'),(1506,'Clients given 5A weighing 14-19.9kg','Clients given 5A weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 14-19.9kg\n Clients given 5A weighing 14-19.9kg\n \n 2022-06-30 11:04:00 UTC\n \n 2023-08-15 09:44: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 1506\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:04:00',4,'2023-08-15 11:44:19',4,0,NULL,NULL,NULL,'f1b1f749-bfcc-4a13-b348-64c59866cc59'),(1507,'Clients given 5A weighing 20-24.9kg','Clients given 5A weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 20-24.9kg\n Clients given 5A weighing 20-24.9kg\n \n 2022-06-30 11:04:47 UTC\n \n 2023-08-15 09:46: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 1507\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 \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 \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 (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','2022-06-30 13:04:47',4,'2023-08-15 11:46:25',4,0,NULL,NULL,NULL,'abad239c-e77e-4577-9ce7-dec2f8fec968'),(1508,'Clients given 5H weighing 0-3.9kg','Clients given 5H weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 0-3.9kg\n Clients given 5H weighing 0-3.9kg\n \n 2022-06-30 11:05:16 UTC\n \n 2022-06-30 11:05: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 1508\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 \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 \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 (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 > 0 and _weight <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:05:16',4,'2022-06-30 13:05:45',4,0,NULL,NULL,NULL,'6197805b-306c-4d08-8146-fa728c86cad0'),(1509,'Clients given 5A weighing 25-34.9kg','Clients given 5A weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 25-34.9kg\n Clients given 5A weighing 25-34.9kg\n \n 2022-06-30 11:05:57 UTC\n \n 2023-08-15 09:48: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 1509\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:05:57',4,'2023-08-15 11:48:51',4,0,NULL,NULL,NULL,'56bc1e3d-3e39-4a2a-be29-f923f3403a9f'),(1510,'Clients given 5H weighing 4-5.9kg','Clients given 5H weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 4-5.9kg\n Clients given 5H weighing 4-5.9kg\n \n 2022-06-30 11:06:12 UTC\n \n 2022-06-30 11:06: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 1510\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 \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 \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 (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 >= 4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:06:12',4,'2022-06-30 13:06:36',4,0,NULL,NULL,NULL,'f46b6d84-55a7-4fd0-af6d-da58bdfdadbc'),(1511,'Clients given 5A weighing >= 35kg','Clients given 5A weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing >= 35kg\n Clients given 5A weighing >= 35kg\n \n 2022-06-30 11:07:03 UTC\n \n 2022-06-30 11:07: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 1511\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:07:03',4,'2022-06-30 13:07:39',4,0,NULL,NULL,NULL,'7313b979-6116-4b8c-8d45-159dce135628'),(1512,'Clients given 5H weighing 6-9.9kg','Clients given 5H weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 6-9.9kg\n Clients given 5H weighing 6-9.9kg\n \n 2022-06-30 11:07:30 UTC\n \n 2022-06-30 11: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 1512\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 \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 \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 (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 >= 6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:07:30',4,'2022-06-30 13:07:53',4,0,NULL,NULL,NULL,'b302e353-da5b-495a-92bf-ac972aa7f94e'),(1513,'Clients given 5B weighing 0-3.9kg','Clients given 5B weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 0-3.9kg\n Clients given 5B weighing 0-3.9kg\n \n 2022-06-30 11:08:51 UTC\n \n 2023-08-15 10:23: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 1513\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 \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 \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 (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>=0 and _weight <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:08:51',4,'2023-08-15 12:23:59',4,0,NULL,NULL,NULL,'01fe5f00-9f8a-44c2-ba40-160f9d05d725'),(1514,'Clients given 5H weighing 10-13.9kg','Clients given 5H weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 10-13.9kg\n Clients given 5H weighing 10-13.9kg\n \n 2022-06-30 11:08:53 UTC\n \n 2022-06-30 11:09: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 1514\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 \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 \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 (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 >= 10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:08:53',4,'2022-06-30 13:09:15',4,0,NULL,NULL,NULL,'fb13cd05-3a8a-4559-9bf2-8f2f4e2df601'),(1515,'Clients given 5H weighing 14-19.9kg','Clients given 5H weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 14-19.9kg\n Clients given 5H weighing 14-19.9kg\n \n 2022-06-30 11:09:36 UTC\n \n 2022-06-30 11:09: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 1515\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 \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 \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 (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 >= 14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:09:36',4,'2022-06-30 13:09:52',4,0,NULL,NULL,NULL,'b99e2ade-ec65-4904-a6ca-e333b39322b6'),(1516,'Clients given 5H weighing 20-24.9kg','Clients given 5H weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 20-24.9kg\n Clients given 5H weighing 20-24.9kg\n \n 2022-06-30 11:10:25 UTC\n \n 2022-06-30 11:10: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 1516\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 \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 \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 (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','2022-06-30 13:10:25',4,'2022-06-30 13:10:43',4,0,NULL,NULL,NULL,'66408707-e4ad-4d2b-973c-77cd0220240c'),(1517,'Clients given 5B weighing 4-5.9kg','Clients given 5B weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 4-5.9kg\n Clients given 5B weighing 4-5.9kg\n \n 2022-06-30 11:10:36 UTC\n \n 2023-08-15 10:49: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 1517\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:10:36',4,'2023-08-15 12:49:11',4,0,NULL,NULL,NULL,'ad0df8d9-d10d-4991-aa03-f7a96d902f69'),(1518,'Clients given 5H weighing 25-34.9kg','Clients given 5H weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 25-34.9kg\n Clients given 5H weighing 25-34.9kg\n \n 2022-06-30 11:11:12 UTC\n \n 2022-06-30 11: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 1518\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 \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 \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 (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 >= 25 and _weight <= 34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:11:12',4,'2022-06-30 13:11:36',4,0,NULL,NULL,NULL,'67f0bd48-1cbf-4d6b-b037-1789f1b9f734'),(1519,'Clients given 5B weighing 6-9.9kg','Clients given 5B weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 6-9.9kg\n Clients given 5B weighing 6-9.9kg\n \n 2022-06-30 11:11:51 UTC\n \n 2023-08-15 10: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 1519\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:11:51',4,'2023-08-15 12:50:59',4,0,NULL,NULL,NULL,'fcd13eef-bda1-46af-993f-ad29378c624a'),(1520,'Clients given 5H weighing >=35kg','Clients given 5H weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing >=35kg\n Clients given 5H weighing >=35kg\n \n 2022-06-30 11:12:13 UTC\n \n 2022-06-30 11:12: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 1520\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 \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 \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 (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 >= 35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:12:13',4,'2022-06-30 13:12:39',4,0,NULL,NULL,NULL,'837029cf-0489-433f-b1f4-93207eb1bae5'),(1521,'Clients given 5B weighing 10-13.9kg','Clients given 5B weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 10-13.9kg\n Clients given 5B weighing 10-13.9kg\n \n 2022-06-30 11:13:00 UTC\n \n 2023-08-15 10:36: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 1521\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:13:00',4,'2023-08-15 12:36:42',4,0,NULL,NULL,NULL,'f90822d7-8137-44bf-9b66-0022b61e1ece'),(1522,'Clients given 5B weighing 14-19.9kg','Clients given 5B weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 14-19.9kg\n Clients given 5B weighing 14-19.9kg\n \n 2022-06-30 11:13:55 UTC\n \n 2023-08-15 10:38: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 1522\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:13:55',4,'2023-08-15 12:38:36',4,0,NULL,NULL,NULL,'247d8f89-0b72-4010-9328-a87600bd22d9'),(1523,'Clients given 5B weighing 20-24.9kg','Clients given 5B weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 20-24.9kg\n Clients given 5B weighing 20-24.9kg\n \n 2022-06-30 11:14:57 UTC\n \n 2023-08-15 10:43: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 1523\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 \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 \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 (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','2022-06-30 13:14:57',4,'2023-08-15 12:43:27',4,0,NULL,NULL,NULL,'b9f0c6b6-a9f7-4ec3-9563-92a43def2068'),(1524,'Clients given 5G weighing 0-3.9kg','Clients given 5G weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 0-3.9kg\n Clients given 5G weighing 0-3.9kg\n \n 2022-06-30 11:15:26 UTC\n \n 2023-08-15 14:15: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 1524\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 \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 \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 (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 > 0 and _weight <= 3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:15:26',4,'2023-08-15 16:15:28',4,0,NULL,NULL,NULL,'d6899230-0f9b-4682-8822-478bfa1ad941'),(1525,'Clients given 5G weighing 4-5.9kg','Clients given 5G weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 4-5.9kg\n Clients given 5G weighing 4-5.9kg\n \n 2022-06-30 11:16:09 UTC\n \n 2023-08-15 14: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 1525\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 \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 \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 (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 >= 4 and _weight <= 5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:16:09',4,'2023-08-15 16:20:31',4,0,NULL,NULL,NULL,'e0607707-f27c-434f-a5cd-44ed04531b3d'),(1526,'Clients given 5B weighing 25-34.9kg','Clients given 5B weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 25-34.9kg\n Clients given 5B weighing 25-34.9kg\n \n 2022-06-30 11:16:20 UTC\n \n 2023-08-15 10:46: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 1526\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:16:20',4,'2023-08-15 12:46:41',4,0,NULL,NULL,NULL,'bd44e473-7f7a-4848-beb6-414f3c87ada1'),(1527,'Clients given 5G weighing 6-9.9kg','Clients given 5G weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 6-9.9kg\n Clients given 5G weighing 6-9.9kg\n \n 2022-06-30 11:17:00 UTC\n \n 2023-08-15 14:21: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 1527\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 \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 \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 (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 >= 6 and _weight <= 9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:17:00',4,'2023-08-15 16:21:24',4,0,NULL,NULL,NULL,'2fa35676-ccce-4bde-a76f-65b9de55fd54'),(1528,'Clients given 5B weighing >= 35kg','Clients given 5B weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing >= 35kg\n Clients given 5B weighing >= 35kg\n \n 2022-06-30 11:17:28 UTC\n \n 2023-08-15 10:21: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 1528\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:17:28',4,'2023-08-15 12:21:09',4,0,NULL,NULL,NULL,'25a796fe-9437-4e38-9c95-6ef6bb295e8e'),(1529,'Clients given 5G weighing 10-13.9kg','Clients given 5G weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 10-13.9kg\n Clients given 5G weighing 10-13.9kg\n \n 2022-06-30 11:18:10 UTC\n \n 2023-08-15 14: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 1529\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 \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 \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 (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 >= 10 and _weight <= 13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:18:10',4,'2023-08-15 16:16:57',4,0,NULL,NULL,NULL,'00ae6c3c-d1c6-44b8-ae77-0b0dadd15e1f'),(1530,'Clients given 5C weighing 0-3.9kg','Clients given 5C weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 0-3.9kg\n Clients given 5C weighing 0-3.9kg\n \n 2022-06-30 11:19:00 UTC\n \n 2023-08-15 10:58: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 1530\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 \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 \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 (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>=0 and _weight <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:19:00',4,'2023-08-15 12:58:29',4,0,NULL,NULL,NULL,'1e058b14-9ac4-4412-96ab-33fd04c575b0'),(1531,'Clients given 5G weighing 14-19.9kg','Clients given 5G weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 14-19.9kg\n Clients given 5G weighing 14-19.9kg\n \n 2022-06-30 11:19:16 UTC\n \n 2023-08-15 14:18: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 1531\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 \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 \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 (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 >= 14 and _weight <= 19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:19:16',4,'2023-08-15 16:18:04',4,0,NULL,NULL,NULL,'2d4f2764-5ad4-4259-88bc-d6cfe29e5365'),(1532,'Clients given 5G weighing 20-24.9kg','Clients given 5G weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 20-24.9kg\n Clients given 5G weighing 20-24.9kg\n \n 2022-06-30 11:19:50 UTC\n \n 2023-08-15 14:18: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 1532\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 \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 \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 (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','2022-06-30 13:19:50',4,'2023-08-15 16:18:49',4,0,NULL,NULL,NULL,'5869ce40-ff99-4614-b3f5-e058345f91a8'),(1533,'Clients given 5G weighing 25 -34.9kg','Clients given 5G weighing 25 -34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 25 -34.9kg\n Clients given 5G weighing 25 -34.9kg\n \n 2022-06-30 11:20:43 UTC\n \n 2023-08-15 14:19: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 1533\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 \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 \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 (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 >= 25 and _weight <= 34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:20:43',4,'2023-08-15 16:19:37',4,0,NULL,NULL,NULL,'3134cfcd-283c-43a2-bb15-8ae6356ebbdd'),(1534,'Clients given 5C weighing 4-5.9kg','Clients given 5C weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 4-5.9kg\n Clients given 5C weighing 4-5.9kg\n \n 2022-06-30 11:21:08 UTC\n \n 2023-08-15 11: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 1534\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:21:08',4,'2023-08-15 13:12:06',4,0,NULL,NULL,NULL,'b6a6e9f5-36ec-414e-95ec-b4a4bb1e7f77'),(1535,'Clients given 5G weighing >=35kg','Clients given 5G weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing >=35kg\n Clients given 5G weighing >=35kg\n \n 2022-06-30 11:21:23 UTC\n \n 2023-08-15 14:14: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 1535\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 \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 \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 (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 >= 35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:21:23',4,'2023-08-15 16:14:25',4,0,NULL,NULL,NULL,'cb219c31-fab1-4f82-a202-48a4a8744a6e'),(1536,'Clients given 5C weighing 6-9.9kg','Clients given 5C weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 6-9.9kg\n Clients given 5C weighing 6-9.9kg\n \n 2022-06-30 11:22:17 UTC\n \n 2023-08-15 11:16: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 1536\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:22:17',4,'2023-08-15 13:16:22',4,0,NULL,NULL,NULL,'e96a3e05-ee48-46f8-ad52-7ea11c785404'),(1537,'Clients given 5F weighing 0-3.9kg','Clients given 5F weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 0-3.9kg\n Clients given 5F weighing 0-3.9kg\n \n 2022-06-30 11:22:53 UTC\n \n 2023-08-15 13:52: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 1537\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 \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 \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 > 0 and _weight <= 3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:22:53',4,'2023-08-15 15:52:56',4,0,NULL,NULL,NULL,'3ed934cc-c2f7-4f9c-ab10-1794412389f1'),(1538,'Clients given 5C weighing 10-13.9kg','Clients given 5C weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 10-13.9kg\n Clients given 5C weighing 10-13.9kg\n \n 2022-06-30 11:23:09 UTC\n \n 2023-08-15 11:00: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 1538\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:23:09',4,'2023-08-15 13:00:14',4,0,NULL,NULL,NULL,'35aa87a9-9aec-42c6-a80d-1f71d2be1ef8'),(1539,'Clients given 5C weighing 14-19.9kg','Clients given 5C weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 14-19.9kg\n Clients given 5C weighing 14-19.9kg\n \n 2022-06-30 11:23:56 UTC\n \n 2023-08-15 11:03: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 1539\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:23:56',4,'2023-08-15 13:03:40',4,0,NULL,NULL,NULL,'8827cdb6-b0b0-4dad-84d7-d06aae03ac3b'),(1540,'Clients given 5C weighing 20-24.9kg','Clients given 5C weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 20-24.9kg\n Clients given 5C weighing 20-24.9kg\n \n 2022-06-30 11:24:56 UTC\n \n 2023-08-15 11:06: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 1540\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 \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 \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 (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','2022-06-30 13:24:56',4,'2023-08-15 13:06:21',4,0,NULL,NULL,NULL,'7cc30e9c-763c-454b-b961-d19c47d2da6a'),(1541,'Clients given 5F weighing 4-5.9kg','Clients given 5F weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 4-5.9kg\n Clients given 5F weighing 4-5.9kg\n \n 2022-06-30 11:24:57 UTC\n \n 2022-06-30 11:26: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 1541\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 \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 \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 >= 4 and _weight <= 5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:24:57',4,'2022-06-30 13:26:23',4,0,NULL,NULL,NULL,'86aec40b-a4e3-49f5-8c61-1b4395bddd75'),(1542,'Clients given 5F weighing 6-9.9kg','Clients given 5F weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 6-9.9kg\n Clients given 5F weighing 6-9.9kg\n \n 2022-06-30 11:25:26 UTC\n \n 2023-08-15 14:09: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 1542\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 \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 \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 >= 6 and _weight <= 9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:25:26',4,'2023-08-15 16:09:20',4,0,NULL,NULL,NULL,'74ddbe48-ab4a-40e2-be97-c0ecfca4ec3d'),(1543,'Clients given 5C weighing 25-34.9kg','Clients given 5C weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 25-34.9kg\n Clients given 5C weighing 25-34.9kg\n \n 2022-06-30 11:26:03 UTC\n \n 2022-06-30 11:26: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 1543\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:26:03',4,'2022-06-30 13:26:35',4,0,NULL,NULL,NULL,'62831d13-bff3-4d96-b097-03c7f656489c'),(1544,'Clients given 5F weighing 10-13.9kg','Clients given 5F weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 10-13.9kg\n Clients given 5F weighing 10-13.9kg\n \n 2022-06-30 11:26:51 UTC\n \n 2023-08-15 13:54: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 1544\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 \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 \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 >= 10 and _weight <= 13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:26:51',4,'2023-08-15 15:54:54',4,0,NULL,NULL,NULL,'32b14f2b-ab48-4905-a130-7cc98fadc7a3'),(1545,'Clients given 5C weighing >= 35kg','Clients given 5C weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing >= 35kg\n Clients given 5C weighing >= 35kg\n \n 2022-06-30 11:27:06 UTC\n \n 2023-08-15 10:56: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 1545\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:27:06',4,'2023-08-15 12:56:19',4,0,NULL,NULL,NULL,'2253da71-2fae-4683-87c0-4e876e27b5d9'),(1546,'Clients given 5F weighing 14-19.9kg','Clients given 5F weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 14-19.9kg\n Clients given 5F weighing 14-19.9kg\n \n 2022-06-30 11:27:37 UTC\n \n 2023-08-15 13:58: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 1546\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 \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 \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 >= 14 and _weight <= 19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:27:37',4,'2023-08-15 15:58:33',4,0,NULL,NULL,NULL,'ce94925c-9501-475d-8ab6-9a34881d6c9a'),(1547,'Clients given 5F weighing 20-24.9kg','Clients given 5F weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 20-24.9kg\n Clients given 5F weighing 20-24.9kg\n \n 2022-06-30 11:28:13 UTC\n \n 2023-08-15 14:00: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 1547\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 \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 \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','2022-06-30 13:28:13',4,'2023-08-15 16:00:55',4,0,NULL,NULL,NULL,'4e2fdf19-88d3-404b-8467-adbaba647c6c'),(1548,'Clients given 5D weighing 0-3.9kg','Clients given 5D weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 0-3.9kg\n Clients given 5D weighing 0-3.9kg\n \n 2022-06-30 11:28:24 UTC\n \n 2023-08-15 11:28: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 1548\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 \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 \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 (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>=0 and _weight <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:28:24',4,'2023-08-15 13:28:55',4,0,NULL,NULL,NULL,'9b7dc1a8-9c16-4ece-bf35-c13c45e27fd9'),(1549,'Clients given 5F weighing 25-34.9kg','Clients given 5F weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 25-34.9kg\n Clients given 5F weighing 25-34.9kg\n \n 2022-06-30 11:28:59 UTC\n \n 2023-08-15 14:02: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 1549\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 \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 \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 >= 25 and _weight <= 34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:28:59',4,'2023-08-15 16:02:41',4,0,NULL,NULL,NULL,'8a336065-e783-4b0b-bfba-d49c0507171c'),(1550,'Clients given 5D weighing 4-5.9kg','Clients given 5D weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 4-5.9kg\n Clients given 5D weighing 4-5.9kg\n \n 2022-06-30 11:29:51 UTC\n \n 2023-08-15 12:02: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 1550\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:29:51',4,'2023-08-15 14:02:22',4,0,NULL,NULL,NULL,'19fcd7c2-7d0e-4f89-8893-b7e56a90f565'),(1551,'Clients given 5F weighing >=35kg','Clients given 5F weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing >=35kg\n Clients given 5F weighing >=35kg\n \n 2022-06-30 11:30:09 UTC\n \n 2023-08-15 13:45: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 1551\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 \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 \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 >= 35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:30:09',4,'2023-08-15 15:45:47',4,0,NULL,NULL,NULL,'8d926451-29fe-44cb-9898-a0aed10c3786'); +INSERT INTO `serialized_object` VALUES (1552,'Clients given 5D weighing 6-9.9kg','Clients given 5D weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 6-9.9kg\n Clients given 5D weighing 6-9.9kg\n \n 2022-06-30 11:30:53 UTC\n \n 2023-08-15 12:03: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 1552\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:30:53',4,'2023-08-15 14:03:43',4,0,NULL,NULL,NULL,'c4e2b4a6-62d3-4828-9088-05f88efd29d0'),(1553,'Clients given 5D weighing 10-13.9kg','Clients given 5D weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 10-13.9kg\n Clients given 5D weighing 10-13.9kg\n \n 2022-06-30 11:32:07 UTC\n \n 2023-08-15 11:52: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 1553\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:32:07',4,'2023-08-15 13:52:13',4,0,NULL,NULL,NULL,'af887c72-8ee7-4273-abe0-8755f691eeb7'),(1554,'Clients given 5E weighing 0-3.9kg','Clients given 5E weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 0-3.9kg\n Clients given 5E weighing 0-3.9kg\n \n 2022-06-30 11:33:14 UTC\n \n 2023-08-15 12:11: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 1554\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 \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 \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 (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 >= 0 and _weight <= 3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:33:14',4,'2023-08-15 14:11:02',4,0,NULL,NULL,NULL,'e79351a3-8b87-48de-879e-7f531c97ae16'),(1555,'Clients given 5D weighing 14-19.9kg','Clients given 5D weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 14-19.9kg\n Clients given 5D weighing 14-19.9kg\n \n 2022-06-30 11:33:21 UTC\n \n 2023-08-15 11:55: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 1555\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:33:21',4,'2023-08-15 13:55:11',4,0,NULL,NULL,NULL,'412170be-ff0c-4690-bc21-2fe362faafb1'),(1556,'Clients given 5E weighing 4-5.9kg','Clients given 5E weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 4-5.9kg\n Clients given 5E weighing 4-5.9kg\n \n 2022-06-30 11:34:03 UTC\n \n 2023-08-15 12:22: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 1556\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 \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 \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 (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 >= 4 and _weight <= 5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:34:03',4,'2023-08-15 14:22:56',4,0,NULL,NULL,NULL,'a6067fc6-8c70-4691-aa23-3e5a7973d4e4'),(1557,'Clients given 5D weighing 20-24.9kg','Clients given 5D weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 20-24.9kg\n Clients given 5D weighing 20-24.9kg\n \n 2022-06-30 11:34:31 UTC\n \n 2023-08-15 11:57: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 1557\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 \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 \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 (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','2022-06-30 13:34:31',4,'2023-08-15 13:57:06',4,0,NULL,NULL,NULL,'b12b32c4-ae91-44c1-bb7a-f2a4f0f74dcc'),(1558,'Clients given 5E weighing 6-9.9kg','Clients given 5E weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 6-9.9kg\n Clients given 5E weighing 6-9.9kg\n \n 2022-06-30 11:34:43 UTC\n \n 2023-08-15 12: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 1558\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 \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 \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 (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 >= 6 and _weight <= 9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:34:43',4,'2023-08-15 14:23:53',4,0,NULL,NULL,NULL,'ddbb6383-120a-4cfc-b376-eb9ec22e891b'),(1559,'Clients given 5E weighing 10-13.9kg','Clients given 5E weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 10-13.9kg\n Clients given 5E weighing 10-13.9kg\n \n 2022-06-30 11:35:22 UTC\n \n 2023-08-15 12:13: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 1559\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 \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 \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 (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 >= 10 and _weight <= 13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:35:22',4,'2023-08-15 14:13:26',4,0,NULL,NULL,NULL,'9334b5ec-d46f-465b-91f5-aba7e4f590a0'),(1560,'Clients given 5D weighing 25-34.9kg','Clients given 5D weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 25-34.9kg\n Clients given 5D weighing 25-34.9kg\n \n 2022-06-30 11:35:31 UTC\n \n 2023-08-15 11:59: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 1560\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:35:31',4,'2023-08-15 13:59:41',4,0,NULL,NULL,NULL,'88ff4abe-3367-4de0-be20-eaa6991568ce'),(1561,'Clients given 5E weighing 14-19.9kg','Clients given 5E weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 14-19.9kg\n Clients given 5E weighing 14-19.9kg\n \n 2022-06-30 11:36:01 UTC\n \n 2023-08-15 12:14: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 1561\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 \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 \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 (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 >= 14 and _weight <= 19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:36:01',4,'2023-08-15 14:14:47',4,0,NULL,NULL,NULL,'1514aaa6-288c-423b-96e6-ae5ee9074647'),(1562,'Clients given 5E weighing 20-24.9kg','Clients given 5E weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 20-24.9kg\n Clients given 5E weighing 20-24.9kg\n \n 2022-06-30 11:36:43 UTC\n \n 2023-08-15 12:20: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 1562\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 \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 \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 (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','2022-06-30 13:36:43',4,'2023-08-15 14:20:37',4,0,NULL,NULL,NULL,'28e98d97-dc6d-412f-89cb-3f19cd4d38b9'),(1563,'Clients given 5D weighing >= 35kg','Clients given 5D weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing >= 35kg\n Clients given 5D weighing >= 35kg\n \n 2022-06-30 11:36:48 UTC\n \n 2023-08-15 11:23: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 1563\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:36:48',4,'2023-08-15 13:23:11',4,0,NULL,NULL,NULL,'b4d8909f-2edb-4730-bf71-446d2fd8867c'),(1564,'Clients given 5E weighing 25-34.9kg','Clients given 5E weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 25-34.9kg\n Clients given 5E weighing 25-34.9kg\n \n 2022-06-30 11:37:59 UTC\n \n 2023-08-15 12:21: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 1564\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 \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 \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 (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 >= 25 and _weight <= 34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:37:59',4,'2023-08-15 14:21:55',4,0,NULL,NULL,NULL,'decbe846-1d21-400e-93c7-d535d80c75c2'),(1565,'Clients given 6A weighing 0-3.9kg','Clients given 6A weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 0-3.9kg\n Clients given 6A weighing 0-3.9kg\n \n 2022-06-30 11:38:28 UTC\n \n 2023-08-15 11:50: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 1565\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:38:28',4,'2023-08-15 13:50:29',4,0,NULL,NULL,NULL,'9612971e-a174-4a5f-8fbd-59eec5a601b2'),(1566,'Clients given 5E weighing >=35kg','Clients given 5E weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing >=35kg\n Clients given 5E weighing >=35kg\n \n 2022-06-30 11:38:46 UTC\n \n 2023-08-15 12: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 1566\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 \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 \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 (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 >= 35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:38:46',4,'2023-08-15 14:08:51',4,0,NULL,NULL,NULL,'8e471ec5-2e65-4ade-9508-52eabac321a3'),(1567,'Clients given 6F weighing 0-3.9kg','Clients given 6F weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 0-3.9kg\n Clients given 6F weighing 0-3.9kg\n \n 2022-06-30 11:41:42 UTC\n \n 2023-08-15 11:55: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 1567\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:41:42',4,'2023-08-15 13:55:19',4,0,NULL,NULL,NULL,'21f2534a-381c-427b-85d0-2e8a156f55cc'),(1568,'Clients given 6A weighing 4-5.9kg','Clients given 6A weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 4-5.9kg\n Clients given 6A weighing 4-5.9kg\n \n 2022-06-30 11:42:04 UTC\n \n 2023-08-15 11:58: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 1568\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:42:04',4,'2023-08-15 13:58:40',4,0,NULL,NULL,NULL,'349f5e74-fd1f-46ca-b279-089ec17daa3c'),(1569,'Clients given 6F weighing 4-5.9kg','Clients given 6F weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 4-5.9kg\n Clients given 6F weighing 4-5.9kg\n \n 2022-06-30 11:42:52 UTC\n \n 2023-08-15 12:01: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 1569\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:42:52',4,'2023-08-15 14:01:56',4,0,NULL,NULL,NULL,'6d6fd933-e915-4eb2-aa0a-5f9a3fc39c9e'),(1570,'Clients given 6A weighing 6-9.9kg','Clients given 6A weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 6-9.9kg\n Clients given 6A weighing 6-9.9kg\n \n 2022-06-30 11:42:56 UTC\n \n 2023-08-15 12:07: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 1570\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:42:56',4,'2023-08-15 14:07:06',4,0,NULL,NULL,NULL,'d6cf3e57-fba8-4961-83e9-e0c69b152e91'),(1571,'Clients given 6F weighing 6-9.9kg','Clients given 6F weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 6-9.9kg\n Clients given 6F weighing 6-9.9kg\n \n 2022-06-30 11:43:28 UTC\n \n 2023-08-15 12:11: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 1571\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:43:28',4,'2023-08-15 14:11:18',4,0,NULL,NULL,NULL,'07ebdb1b-42fd-4338-9880-b53a0e857d14'),(1572,'Clients given 6A weighing 10-13.9kg','Clients given 6A weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 10-13.9kg\n Clients given 6A weighing 10-13.9kg\n \n 2022-06-30 11:43:45 UTC\n \n 2023-08-15 12:19: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 1572\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:43:45',4,'2023-08-15 14:19:36',4,0,NULL,NULL,NULL,'de6af126-f558-4acf-b061-982dbfac0025'),(1573,'Clients given 6F weighing 10-13.9kg','Clients given 6F weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 10-13.9kg\n Clients given 6F weighing 10-13.9kg\n \n 2022-06-30 11:44:06 UTC\n \n 2023-08-15 12:14: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 1573\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:44:06',4,'2023-08-15 14:14:29',4,0,NULL,NULL,NULL,'e77aeb5b-70e2-46a1-9451-be37911a5dc0'),(1574,'Clients given 6A weighing 14-19.9kg','Clients given 6A weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 14-19.9kg\n Clients given 6A weighing 14-19.9kg\n \n 2022-06-30 11:44:40 UTC\n \n 2023-08-15 13:36: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 1574\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:44:40',4,'2023-08-15 15:36:18',4,0,NULL,NULL,NULL,'6850d21e-415b-4941-aa12-ddcf45ebf1cf'),(1575,'Clients given 6F weighing 14-19.9kg','Clients given 6F weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 14-19.9kg\n Clients given 6F weighing 14-19.9kg\n \n 2022-06-30 11:44:51 UTC\n \n 2023-08-15 13:39: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 1575\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:44:51',4,'2023-08-15 15:39:53',4,0,NULL,NULL,NULL,'bffbdb83-5c53-4429-baca-46ef480cbbdd'),(1576,'Clients given 6A weighing 20-24.9kg','Clients given 6A weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 20-24.9kg\n Clients given 6A weighing 20-24.9kg\n \n 2022-06-30 11:45:34 UTC\n \n 2023-08-15 13:43: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 1576\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 \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 \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 (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','2022-06-30 13:45:34',4,'2023-08-15 15:43:08',4,0,NULL,NULL,NULL,'00c9ee8c-dd26-4de8-8d76-65235331fc58'),(1577,'Clients given 6F weighing 20-24.9kg','Clients given 6F weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 20-24.9kg\n Clients given 6F weighing 20-24.9kg\n \n 2022-06-30 11:45:40 UTC\n \n 2023-08-15 13:46: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 1577\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 \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 \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 (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','2022-06-30 13:45:40',4,'2023-08-15 15:46:12',4,0,NULL,NULL,NULL,'1907619e-e315-4136-b63d-ebb12d9a8fc1'),(1578,'Clients given 6F weighing 25-34.9kg','Clients given 6F weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 25-34.9kg\n Clients given 6F weighing 25-34.9kg\n \n 2022-06-30 11:46:30 UTC\n \n 2023-08-15 13: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 1578\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:46:30',4,'2023-08-15 15:54:43',4,0,NULL,NULL,NULL,'67151923-545c-44f9-955c-705bd4b86bd8'),(1579,'Clients given 6A weighing 25-34.9kg','Clients given 6A weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 25-34.9kg\n Clients given 6A weighing 25-34.9kg\n \n 2022-06-30 11:46:33 UTC\n \n 2023-08-15 13:52: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 1579\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:46:33',4,'2023-08-15 15:52:05',4,0,NULL,NULL,NULL,'c4410a3f-a272-4f5a-8b68-c293b482c8f2'),(1580,'Clients given 6F weighing >=35kg','Clients given 6F weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing >=35kg\n Clients given 6F weighing >=35kg\n \n 2022-06-30 11:47:14 UTC\n \n 2023-08-15 14:01: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 1580\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:47:14',4,'2023-08-15 16:01:34',4,0,NULL,NULL,NULL,'88e71ca5-8e27-438a-ad22-12007acc675a'),(1581,'Clients given 6A weighing >= 35kg','Clients given 6A weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing >= 35kg\n Clients given 6A weighing >= 35kg\n \n 2022-06-30 11:47:26 UTC\n \n 2023-08-15 13:58: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 1581\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:47:26',4,'2023-08-15 15:58:50',4,0,NULL,NULL,NULL,'120fc355-ea4b-4d74-9df3-713f396ad4d5'),(1582,'Clients given 6B weighing 0-3.9kg','Clients given 6B weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 0-3.9kg\n Clients given 6B weighing 0-3.9kg\n \n 2022-06-30 11:49:06 UTC\n \n 2023-08-15 11:51: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 1582\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:49:06',4,'2023-08-15 13:51:04',4,0,NULL,NULL,NULL,'c94b83be-7708-46c9-803c-369d803ce612'),(1583,'Clients given 6E weighing 0-3.9kg','Clients given 6E weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 0-3.9kg\n Clients given 6E weighing 0-3.9kg\n \n 2022-06-30 11:49:10 UTC\n \n 2023-08-15 11:55: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 1583\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:49:10',4,'2023-08-15 13:55:28',4,0,NULL,NULL,NULL,'79f4464f-be3a-4f76-b911-1324264edb34'),(1584,'Clients given 6E weighing 4-5.9kg','Clients given 6E weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 4-5.9kg\n Clients given 6E weighing 4-5.9kg\n \n 2022-06-30 11:50:19 UTC\n \n 2023-08-15 12:02: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 1584\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:50:19',4,'2023-08-15 14:02:30',4,0,NULL,NULL,NULL,'c940a6d2-b183-4f3d-99c3-757c98c1d95d'),(1585,'Clients given 6B weighing 4-5.9kg','Clients given 6B weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 4-5.9kg\n Clients given 6B weighing 4-5.9kg\n \n 2022-06-30 11:50:41 UTC\n \n 2023-08-15 12:03: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 1585\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:50:41',4,'2023-08-15 14:03:18',4,0,NULL,NULL,NULL,'b03e49d3-e03b-4a31-b0c9-dc33942ca80b'),(1586,'Clients given 6E weighing 6-9.9kg','Clients given 6E weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 6-9.9kg\n Clients given 6E weighing 6-9.9kg\n \n 2022-06-30 11:51:01 UTC\n \n 2023-08-15 12: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 1586\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:51:01',4,'2023-08-15 14:11:10',4,0,NULL,NULL,NULL,'b0f0ed35-fe90-4552-83a7-e10c1b509fdb'),(1587,'Clients given 6B weighing 6-9.9kg','Clients given 6B weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 6-9.9kg\n Clients given 6B weighing 6-9.9kg\n \n 2022-06-30 11:51:24 UTC\n \n 2023-08-15 12:07: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 1587\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:51:24',4,'2023-08-15 14:07:40',4,0,NULL,NULL,NULL,'9b75e9b1-6086-4d10-aa5d-f574d58c2f9b'),(1588,'Clients given 6E weighing 10-13.9kg','Clients given 6E weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 10-13.9kg\n Clients given 6E weighing 10-13.9kg\n \n 2022-06-30 11:51:37 UTC\n \n 2023-08-15 12:15: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 1588\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:51:37',4,'2023-08-15 14:15:07',4,0,NULL,NULL,NULL,'4ab54017-730b-443b-b1a4-c7fb57c16069'),(1589,'Clients given 6B weighing 10-13.9kg','Clients given 6B weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 10-13.9kg\n Clients given 6B weighing 10-13.9kg\n \n 2022-06-30 11:52:19 UTC\n \n 2023-08-15 12:18: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 1589\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:52:19',4,'2023-08-15 14:18:48',4,0,NULL,NULL,NULL,'439b52c1-c9d5-4366-9819-994f121bf0fa'),(1590,'Clients given 6E weighing 14-19.9kg','Clients given 6E weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 14-19.9kg\n Clients given 6E weighing 14-19.9kg\n \n 2022-06-30 11:52:28 UTC\n \n 2023-08-15 13:39: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 1590\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:52:28',4,'2023-08-15 15:39:35',4,0,NULL,NULL,NULL,'4a2873d6-97bb-42b9-8e4f-4786bf854462'),(1591,'Clients given 6E weighing 20-24.9kg','Clients given 6E weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 20-24.9kg\n Clients given 6E weighing 20-24.9kg\n \n 2022-06-30 11:53:12 UTC\n \n 2023-08-15 13:45: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 1591\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 \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 \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 (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','2022-06-30 13:53:12',4,'2023-08-15 15:45:54',4,0,NULL,NULL,NULL,'e129484c-9b6b-4ed5-a0b8-da691370e459'),(1592,'Clients given 6B weighing 14-19.9kg','Clients given 6B weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 14-19.9kg\n Clients given 6B weighing 14-19.9kg\n \n 2022-06-30 11:53:32 UTC\n \n 2023-08-15 13:38: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 1592\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:53:32',4,'2023-08-15 15:38:03',4,0,NULL,NULL,NULL,'af7d5255-1e37-4def-b26d-dcded87c1ded'),(1593,'Clients given 6E weighing 25-34.9kg','Clients given 6E weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 25-34.9kg\n Clients given 6E weighing 25-34.9kg\n \n 2022-06-30 11:54:08 UTC\n \n 2023-08-15 13:54: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 1593\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:54:08',4,'2023-08-15 15:54:22',4,0,NULL,NULL,NULL,'5c8f4cdd-6c22-4df0-8d12-801a66ccff55'),(1594,'Clients given 6B weighing 20-24.9kg','Clients given 6B weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 20-24.9kg\n Clients given 6B weighing 20-24.9kg\n \n 2022-06-30 11:54:35 UTC\n \n 2023-08-15 13:43: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 1594\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 \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 \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 (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','2022-06-30 13:54:35',4,'2023-08-15 15:43:29',4,0,NULL,NULL,NULL,'3d5ca230-bb1a-40ad-9a13-ae3d4a7868c1'),(1595,'Clients given 6E weighing >=35kg','Clients given 6E weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing >=35kg\n Clients given 6E weighing >=35kg\n \n 2022-06-30 11:54:50 UTC\n \n 2023-08-15 14: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 1595\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:54:50',4,'2023-08-15 16:01:10',4,0,NULL,NULL,NULL,'0ed30402-06d4-4a91-ab30-8aa4cb05f973'),(1596,'Clients given 6B weighing 25-34.9kg','Clients given 6B weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 25-34.9kg\n Clients given 6B weighing 25-34.9kg\n \n 2022-06-30 11:55:30 UTC\n \n 2023-08-15 13:52: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 1596\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:55:30',4,'2023-08-15 15:52:19',4,0,NULL,NULL,NULL,'760b7d9e-5a7e-4a13-9517-59f18a299d60'),(1597,'Clients given 6B weighing >= 35kg','Clients given 6B weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing >= 35kg\n Clients given 6B weighing >= 35kg\n \n 2022-06-30 11:56:44 UTC\n \n 2023-08-15 14:00: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 1597\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:56:44',4,'2023-08-15 16:00:19',4,0,NULL,NULL,NULL,'89e94627-eb6a-4b05-8b5c-7c06482c67da'),(1598,'Clients given 6D weighing 0-3.9kg','Clients given 6D weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 0-3.9kg\n Clients given 6D weighing 0-3.9kg\n \n 2022-06-30 11:57:07 UTC\n \n 2023-08-15 11:55: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 1598\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:57:07',4,'2023-08-15 13:55:38',4,0,NULL,NULL,NULL,'c5ecfc78-4201-495c-9c7d-042b046d6c3d'),(1599,'Clients given 6D weighing 4-5.9kg','Clients given 6D weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 4-5.9kg\n Clients given 6D weighing 4-5.9kg\n \n 2022-06-30 11:57:58 UTC\n \n 2023-08-15 12:02: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 1599\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:57:58',4,'2023-08-15 14:02:40',4,0,NULL,NULL,NULL,'25950d8e-2a7a-484f-8674-e94ba2fc9071'),(1600,'Clients given 6C weighing 0-3.9kg','Clients given 6C weighing 0-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 0-3.9kg\n Clients given 6C weighing 0-3.9kg\n \n 2022-06-30 11:58:17 UTC\n \n 2023-08-15 11:52: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 1600\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 \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 \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 (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 <=3.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:58:17',4,'2023-08-15 13:52:01',4,0,NULL,NULL,NULL,'6eff51d3-2d07-44db-a617-ff288d027867'),(1601,'Clients given 6D weighing 6-9.9kg','Clients given 6D weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 6-9.9kg\n Clients given 6D weighing 6-9.9kg\n \n 2022-06-30 11:58:42 UTC\n \n 2023-08-15 12:10: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 1601\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:58:42',4,'2023-08-15 14:10:38',4,0,NULL,NULL,NULL,'0b2e111f-f266-4a34-ba0b-4080607ca595'),(1602,'Clients given 6D weighing 10-13.9kg','Clients given 6D weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 10-13.9kg\n Clients given 6D weighing 10-13.9kg\n \n 2022-06-30 11:59:37 UTC\n \n 2023-08-15 12:15: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 1602\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 13:59:37',4,'2023-08-15 14:15:29',4,0,NULL,NULL,NULL,'d13d961e-4f19-4d97-88f5-f0795b285859'),(1603,'Clients given 6D weighing 14-19.9kg','Clients given 6D weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 14-19.9kg\n Clients given 6D weighing 14-19.9kg\n \n 2022-06-30 12:00:32 UTC\n \n 2023-08-15 13:39: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 1603\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:00:32',4,'2023-08-15 15:39:12',4,0,NULL,NULL,NULL,'ba0967aa-34e7-4df6-a75b-cbe7c8b52cea'),(1604,'Clients given 6C weighing 4-5.9kg','Clients given 6C weighing 4-5.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 4-5.9kg\n Clients given 6C weighing 4-5.9kg\n \n 2022-06-30 12:00:54 UTC\n \n 2023-08-15 12:02: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 1604\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 \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 \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 (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>=4 and _weight <=5.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:00:54',4,'2023-08-15 14:02:57',4,0,NULL,NULL,NULL,'9538730a-29f7-45cc-a6e5-4b20a1b80f2f'),(1605,'Clients given 6D weighing 20-24.9kg','Clients given 6D weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 20-24.9kg\n Clients given 6D weighing 20-24.9kg\n \n 2022-06-30 12:01:12 UTC\n \n 2023-08-15 13:45: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 1605\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 \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 \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 (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','2022-06-30 14:01:12',4,'2023-08-15 15:45:42',4,0,NULL,NULL,NULL,'87b14d09-b20e-47d1-b20e-c38bc338df15'),(1606,'Clients given 6D weighing 25-34.9kg','Clients given 6D weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 25-34.9kg\n Clients given 6D weighing 25-34.9kg\n \n 2022-06-30 12:01:59 UTC\n \n 2023-08-15 13: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 1606\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:01:59',4,'2023-08-15 15:54:05',4,0,NULL,NULL,NULL,'9b8508f6-6c59-4408-90d1-4366ad9f3df7'),(1607,'Clients given 6C weighing 6-9.9kg','Clients given 6C weighing 6-9.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 6-9.9kg\n Clients given 6C weighing 6-9.9kg\n \n 2022-06-30 12:02:20 UTC\n \n 2023-08-15 12:08: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 1607\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 \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 \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 (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>=6 and _weight <=9.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:02:20',4,'2023-08-15 14:08:10',4,0,NULL,NULL,NULL,'021aecf8-4314-4feb-921d-dbab609bce88'),(1608,'Clients given 6D weighing >=35kg','Clients given 6D weighing >=35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing >=35kg\n Clients given 6D weighing >=35kg\n \n 2022-06-30 12:02:42 UTC\n \n 2023-08-15 14:00: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 1608\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:02:42',4,'2023-08-15 16:00:51',4,0,NULL,NULL,NULL,'6b8cf9ee-1659-46da-8aab-1580ccd82fe7'),(1609,'Clients given 6C weighing 10-13.9kg','Clients given 6C weighing 10-13.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 10-13.9kg\n Clients given 6C weighing 10-13.9kg\n \n 2022-06-30 12:03:07 UTC\n \n 2023-08-15 12:15: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 1609\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 \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 \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 (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>=10 and _weight <=13.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:03:07',4,'2023-08-15 14:15:45',4,0,NULL,NULL,NULL,'e43ddc56-97c9-4c2b-9dd1-4439ab2d154e'),(1610,'Clients given 6C weighing 14-19.9kg','Clients given 6C weighing 14-19.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 14-19.9kg\n Clients given 6C weighing 14-19.9kg\n \n 2022-06-30 12:03:52 UTC\n \n 2023-08-15 13:38: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 1610\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 \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 \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 (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>=14 and _weight <=19.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:03:52',4,'2023-08-15 15:38:51',4,0,NULL,NULL,NULL,'7cc34bd7-01dc-4e10-97b4-3aabce82e0d2'),(1611,'Clients given 6C weighing 20-24.9kg','Clients given 6C weighing 20-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 20-24.9kg\n Clients given 6C weighing 20-24.9kg\n \n 2022-06-30 12:05:08 UTC\n \n 2023-08-15 13:45: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 1611\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 \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 \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 (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','2022-06-30 14:05:08',4,'2023-08-15 15:45:29',4,0,NULL,NULL,NULL,'eb9fff17-d2d9-4c0a-a4ff-919fe86f2cfe'),(1612,'Clients given 6C weighing 25-34.9kg','Clients given 6C weighing 25-34.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 25-34.9kg\n Clients given 6C weighing 25-34.9kg\n \n 2022-06-30 12:06:35 UTC\n \n 2023-08-15 13:52: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 1612\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 \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 \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 (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>=25 and _weight <=34.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:06:35',4,'2023-08-15 15:52:38',4,0,NULL,NULL,NULL,'95004055-2dd1-4b3c-9536-877974c6fc23'),(1613,'Clients given 6C weighing >= 35kg','Clients given 6C weighing >= 35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing >= 35kg\n Clients given 6C weighing >= 35kg\n \n 2022-06-30 12:07:48 UTC\n \n 2023-08-15 14:00: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 1613\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 \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 \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 (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>=35)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2022-06-30 14:07:48',4,'2023-08-15 16:00:36',4,0,NULL,NULL,NULL,'a5659098-23a4-41c0-8bbd-12dd4c9bca64'),(1614,'Clients given 4C weighing 0-3.9kg','Clients given 4C weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.SqlIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 0-3.9kg\n Clients given 4C weighing 0-3.9kg\n \n 2022-06-30 12:15:27 UTC\n \n','2022-06-30 14:15:27',4,NULL,NULL,0,NULL,NULL,NULL,'46894193-4656-4941-9050-4498338da679'),(1615,'Clients given 4C weighing 0-3.9kg','Clients given 4C weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 0-3.9kg\n Clients given 4C weighing 0-3.9kg\n \n 2022-06-30 12:16:38 UTC\n \n 2022-06-30 12:20: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 1615\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:16:38',4,'2022-06-30 14:20:27',4,0,NULL,NULL,NULL,'4a2b667a-930c-4d98-9073-18aa9e6104ec'),(1616,'Clients given 4C weighing 4-5.9kg','Clients given 4C weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 4-5.9kg\n Clients given 4C weighing 4-5.9kg\n \n 2022-06-30 12:21:22 UTC\n \n 2022-06-30 12: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 1616\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:21:22',4,'2022-06-30 14:23:05',4,0,NULL,NULL,NULL,'aa294dde-6440-4b72-ab4a-d5b782cec371'),(1617,'Clients given 4C weighing 6-9.9kg','Clients given 4C weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 6-9.9kg\n Clients given 4C weighing 6-9.9kg\n \n 2022-06-30 12:23:45 UTC\n \n 2022-06-30 12:24: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 1617\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:23:45',4,'2022-06-30 14:24:45',4,0,NULL,NULL,NULL,'5a98d199-a896-47ec-830e-56cd2fef0351'),(1618,'Clients given 4C weighing 10-13.9kg','Clients given 4C weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 10-13.9kg\n Clients given 4C weighing 10-13.9kg\n \n 2022-06-30 12:25:23 UTC\n \n 2022-06-30 12:26: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 1618\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:25:23',4,'2022-06-30 14:26:36',4,0,NULL,NULL,NULL,'bc8cd79c-b1fd-4956-8f87-596d56a8b0b9'),(1619,'Clients given 4C weighing 14-19.9kg','Clients given 4C weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 14-19.9kg\n Clients given 4C weighing 14-19.9kg\n \n 2022-06-30 12:27:19 UTC\n \n 2022-06-30 12:28: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 1619\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:27:19',4,'2022-06-30 14:28:17',4,0,NULL,NULL,NULL,'220abe15-cbb2-464a-bb57-fb1e75ad56c6'),(1620,'Clients given 4C weighing 20-24.9kg','Clients given 4C weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 20-24.9kg\n Clients given 4C weighing 20-24.9kg\n \n 2022-06-30 12:28:52 UTC\n \n 2022-06-30 12: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 1620\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:28:52',4,'2022-06-30 14:29:51',4,0,NULL,NULL,NULL,'0e4c3cca-5e54-4f77-a359-6c5a47141593'),(1621,'Clients given 4C weighing 25-34.9kg','Clients given 4C weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing 25-34.9kg\n Clients given 4C weighing 25-34.9kg\n \n 2022-06-30 12:30:29 UTC\n \n 2022-06-30 12:31: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 1621\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:30:29',4,'2022-06-30 14:31:26',4,0,NULL,NULL,NULL,'d1810771-902c-44c5-b1a9-988f037cf87d'),(1622,'Clients given 4C weighing >= 35kg','Clients given 4C weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C weighing >= 35kg\n Clients given 4C weighing >= 35kg\n \n 2022-06-30 12:32:03 UTC\n \n 2022-06-30 12:33: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 1622\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:32:03',4,'2022-06-30 14:33:13',4,0,NULL,NULL,NULL,'1d840c5f-240c-4159-8a72-6b0db642b53f'),(1623,'Clients given 4D weighing 0-3.9kg','Clients given 4D weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 0-3.9kg\n Clients given 4D weighing 0-3.9kg\n \n 2022-06-30 12:33:59 UTC\n \n 2022-06-30 12:36: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 1623\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:33:59',4,'2022-06-30 14:36:06',4,0,NULL,NULL,NULL,'0746d03a-e518-473c-809e-f764e275f42a'),(1624,'Clients given 4D weighing 4-5.9kg','Clients given 4D weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 4-5.9kg\n Clients given 4D weighing 4-5.9kg\n \n 2022-06-30 12:36:44 UTC\n \n 2022-06-30 12:38: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 1624\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:36:44',4,'2022-06-30 14:38:51',4,0,NULL,NULL,NULL,'fdaff2b0-2a93-4eed-8a21-37b4493a93d8'),(1625,'Clients given 4D weighing 6-9.9kg','Clients given 4D weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 6-9.9kg\n Clients given 4D weighing 6-9.9kg\n \n 2022-06-30 12:37:11 UTC\n \n 2022-06-30 12:39: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 1625\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:37:11',4,'2022-06-30 14:39:41',4,0,NULL,NULL,NULL,'f7342534-15b0-4b7f-abf7-4689c7510e5d'),(1626,'Clients given 4D weighing 10-13.9kg','Clients given 4D weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 10-13.9kg\n Clients given 4D weighing 10-13.9kg\n \n 2022-06-30 12:40:08 UTC\n \n 2022-06-30 12:40: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 1626\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:40:08',4,'2022-06-30 14:40:58',4,0,NULL,NULL,NULL,'f70b046a-7684-4087-85ac-b8e890c99a7d'),(1627,'Clients given 4D weighing 14-19.9kg','Clients given 4D weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 14-19.9kg\n Clients given 4D weighing 14-19.9kg\n \n 2022-06-30 12:41:22 UTC\n \n 2022-06-30 12:46: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 1627\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:41:22',4,'2022-06-30 14:46:15',4,0,NULL,NULL,NULL,'a78b89dd-1172-4ae3-9db1-252697c46714'),(1628,'Children ARV Regimen_1stLine_2022','Children ARV Regimen_1stLine','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_2022\n Children ARV Regimen_1stLine\n \n 2022-06-30 12:44:42 UTC\n \n 2022-06-30 12:44: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 1628\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','2022-06-30 14:44:42',4,'2022-06-30 14:44:52',4,0,NULL,NULL,NULL,'6d96f107-4e14-48ff-b6d7-c845d87e37e1'),(1629,'Children ARV Regimen_1stLine_2022 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_2022 Data Set\n \n 2022-06-30 12:44:52 UTC\n \n 2022-06-30 19:13: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 1629\n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 4C0to3.9\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_Age\n Children 0to14\n \n \n \n \n \n 4C10to13.9\n \n \n \n \n \n \n \n \n \n 4C14to19.9\n \n \n \n \n \n \n \n \n \n 4C20to24.9\n \n \n \n \n \n \n \n \n \n 4C25to34.9\n \n \n \n \n \n \n \n \n \n 4C35plus\n \n \n \n \n \n \n \n \n \n 4C4to5.9\n \n \n \n \n \n \n \n \n \n 4C6to9.9\n \n \n \n \n \n \n \n \n \n 4D0to3.9\n \n \n \n \n \n \n \n \n \n 4D10to13.9\n \n \n \n \n \n \n \n \n \n 4D14to19.9\n \n \n \n \n \n \n \n \n \n 4D20to24.9\n \n \n \n \n \n \n \n \n \n 4D25to34.9\n \n \n \n \n \n \n \n \n \n 4D35plus\n \n \n \n \n \n \n \n \n \n 4D4to5.9\n \n \n \n \n \n \n \n \n \n 4D6to9.9\n \n \n \n \n \n \n \n \n \n 4E0to3.9\n \n \n \n \n \n \n \n \n \n 4E10to13.9\n \n \n \n \n \n \n \n \n \n 4E14to19.9\n \n \n \n \n \n \n \n \n \n 4E20to24.9\n \n \n \n \n \n \n \n \n \n 4E25to34.9\n \n \n \n \n \n \n \n \n \n 4E35plus\n \n \n \n \n \n \n \n \n \n 4E4to5.9\n \n \n \n \n \n \n \n \n \n 4E6to9.9\n \n \n \n \n \n \n \n \n \n 4F0to3.9\n \n \n \n \n \n \n \n \n \n 4F10to13.9\n \n \n \n \n \n \n \n \n \n 4F14to19.9\n \n \n \n \n \n \n \n \n \n 4F20to24.9\n \n \n \n \n \n \n \n \n \n 4F25to34.9\n \n \n \n \n \n \n \n \n \n 4F35plus\n \n \n \n \n \n \n \n \n \n 4F4to5.9\n \n \n \n \n \n \n \n \n \n 4F6to9.9\n \n \n \n \n \n \n \n \n \n 4G0to3.9\n \n \n \n \n \n \n \n \n \n 4G10to13.9\n \n \n \n \n \n \n \n \n \n 4G14to19.9\n \n \n \n \n \n \n \n \n \n 4G20to24.9\n \n \n \n \n \n \n \n \n \n 4G25to34.9\n \n \n \n \n \n \n \n \n \n 4G35plus\n \n \n \n \n \n \n \n \n \n 4G4to5.9\n \n \n \n \n \n \n \n \n \n 4G6to9.9\n \n \n \n \n \n \n \n \n \n 4H0to3.9\n \n \n \n \n \n \n \n \n \n 4H10to13.9\n \n \n \n \n \n \n \n \n \n 4H14to19.9\n \n \n \n \n \n \n \n \n \n 4H20to24.9\n \n \n \n \n \n \n \n \n \n 4H25to34.9\n \n \n \n \n \n \n \n \n \n 4H35plus\n \n \n \n \n \n \n \n \n \n 4H4to5.9\n \n \n \n \n \n \n \n \n \n 4H6to9.9\n \n \n \n \n \n \n \n \n \n 4J0to3.9\n \n \n \n \n \n \n \n \n \n 4J10to13.9\n \n \n \n \n \n \n \n \n \n 4J14to19.9\n \n \n \n \n \n \n \n \n \n 4J20to24.9\n \n \n \n \n \n \n \n \n \n 4J25to34.9\n \n \n \n \n \n \n \n \n \n 4J35plus\n \n \n \n \n \n \n \n \n \n 4J4to5.9\n \n \n \n \n \n \n \n \n \n 4J6to9.9\n \n \n \n \n \n \n \n \n \n 4K0to3.9\n \n \n \n \n \n \n \n \n \n 4K10to13.9\n \n \n \n \n \n \n \n \n \n 4K14to19.9\n \n \n \n \n \n \n \n \n \n 4K20to24.9\n \n \n \n \n \n \n \n \n \n 4K25to34.9\n \n \n \n \n \n \n \n \n \n 4K35plus\n \n \n \n \n \n \n \n \n \n 4K4to5.9\n \n \n \n \n \n \n \n \n \n 4K6to9.9\n \n \n \n \n \n \n \n \n \n 4L0to3.9\n \n \n \n \n \n \n \n \n \n 4L10to13.9\n \n \n \n \n \n \n \n \n \n 4L14to19.9\n \n \n \n \n \n \n \n \n \n 4L20to24.9\n \n \n \n \n \n \n \n \n \n 4L25to34.9\n \n \n \n \n \n \n \n \n \n 4L35plus\n \n \n \n \n \n \n \n \n \n 4L4to5.9\n \n \n \n \n \n \n \n \n \n 4L6to9.9\n \n \n \n \n \n \n \n \n \n','2022-06-30 12:44:52',4,'2022-06-30 19:13:55',4,0,NULL,NULL,NULL,'72dc6096-f429-4c40-93bf-fbf45c22d970'),(1630,'Clients given 4D weighing 20-24.9kg','Clients given 4D weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 20-24.9kg\n Clients given 4D weighing 20-24.9kg\n \n 2022-06-30 12:46:40 UTC\n \n 2022-06-30 12:47: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 1630\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:46:40',4,'2022-06-30 14:47:39',4,0,NULL,NULL,NULL,'6c0b4f36-cc2c-4d85-a2ad-c5b5bf36b66b'),(1631,'Clients given 4D weighing 25-34.9kg','Clients given 4D weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing 25-34.9kg\n Clients given 4D weighing 25-34.9kg\n \n 2022-06-30 12:48:05 UTC\n \n 2022-06-30 12:49: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 1631\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:48:05',4,'2022-06-30 14:49:27',4,0,NULL,NULL,NULL,'1c5157a7-08d8-4eb5-99df-f2ca1825baaa'),(1632,'Clients given 4D weighing >= 35kg','Clients given 4D weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D weighing >= 35kg\n Clients given 4D weighing >= 35kg\n \n 2022-06-30 12:48:59 UTC\n \n 2022-06-30 12:50: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 1632\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:48:59',4,'2022-06-30 14:50:46',4,0,NULL,NULL,NULL,'5cbfb29b-e0b1-42b0-b7f5-a1b561ae3bb5'),(1633,'Clients given 4E weighing 0-3.9kg','Clients given 4E weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 0-3.9kg\n Clients given 4E weighing 0-3.9kg\n \n 2022-06-30 12:50:28 UTC\n \n 2022-06-30 12:54: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 1633\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:50:28',4,'2022-06-30 14:54:40',4,0,NULL,NULL,NULL,'36f7fe8c-f369-4152-a361-bc941ca32f35'),(1634,'Clients given 4E weighing 4-5.9kg','Clients given 4E weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 4-5.9kg\n Clients given 4E weighing 4-5.9kg\n \n 2022-06-30 12:54:09 UTC\n \n 2022-06-30 12:55: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 1634\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:54:09',4,'2022-06-30 14:55:44',4,0,NULL,NULL,NULL,'d6c46caf-e87c-4654-963f-91039f99e100'),(1635,'Clients given 4E weighing 6-9.9kg','Clients given 4E weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 6-9.9kg\n Clients given 4E weighing 6-9.9kg\n \n 2022-06-30 12:57:00 UTC\n \n 2022-06-30 13:15: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 1635\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 14:57:00',4,'2022-06-30 15:15:29',4,0,NULL,NULL,NULL,'2c954752-aaeb-427b-8cef-714be116f8d5'),(1636,'Clients given 4E weighing 10-13.9kg','Clients given 4E weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 10-13.9kg\n Clients given 4E weighing 10-13.9kg\n \n 2022-06-30 13:16:23 UTC\n \n 2022-06-30 13:20: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 1636\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:16:23',4,'2022-06-30 15:20:47',4,0,NULL,NULL,NULL,'92eb0675-5667-4202-ae12-91e31e89bc0a'),(1637,'Clients given 4K weighing 0-3.9kg','Clients given 4K weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 0-3.9kg\n Clients given 4K weighing 0-3.9kg\n \n 2022-06-30 13:21:01 UTC\n \n 2022-06-30 13:22: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 1637\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:21:01',4,'2022-06-30 15:22:04',4,0,NULL,NULL,NULL,'5166d416-8394-41a8-a7bf-cddf0f4573f9'),(1638,'Clients given 4E weighing 14-19.9kg','Clients given 4E weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 14-19.9kg\n Clients given 4E weighing 14-19.9kg\n \n 2022-06-30 13:21:21 UTC\n \n 2022-06-30 13:23: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 1638\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:21:21',4,'2022-06-30 15:23:24',4,0,NULL,NULL,NULL,'7c801f27-0d0e-4f8e-8d16-c9abbbc1d70f'),(1639,'Clients given 4K weighing 4-5.9kg','Clients given 4K weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 4-5.9kg\n Clients given 4K weighing 4-5.9kg\n \n 2022-06-30 13:22:30 UTC\n \n 2022-06-30 13:23: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 1639\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:22:30',4,'2022-06-30 15:23:19',4,0,NULL,NULL,NULL,'c3840473-881e-4c28-8b70-08ee65d51205'),(1640,'Clients given 4E weighing 20-24.9kg','Clients given 4E weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 20-24.9kg\n Clients given 4E weighing 20-24.9kg\n \n 2022-06-30 13:22:54 UTC\n \n 2022-06-30 13:24: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 1640\n COUNT\n \n \n \n \n endDate\n ${startDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:22:54',4,'2022-06-30 15:24:23',4,0,NULL,NULL,NULL,'7171def2-3caa-415e-8d0c-ae70c50ee52a'),(1641,'Clients given 4K weighing 6-9.9kg','Clients given 4K weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 6-9.9kg\n Clients given 4K weighing 6-9.9kg\n \n 2022-06-30 13:23:54 UTC\n \n 2022-06-30 13:24: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 1641\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:23:54',4,'2022-06-30 15:24:45',4,0,NULL,NULL,NULL,'2dc1198d-9268-4a29-b96d-7ac8921d3551'),(1642,'Clients given 4E weighing 25-34.9kg','Clients given 4E weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing 25-34.9kg\n Clients given 4E weighing 25-34.9kg\n \n 2022-06-30 13:24:00 UTC\n \n 2022-06-30 13:25: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 1642\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:24:00',4,'2022-06-30 15:25:27',4,0,NULL,NULL,NULL,'40ac2a8b-12d5-4b3d-bea2-b63e3d969db9'),(1643,'Clients given 4E weighing >= 35kg','Clients given 4E weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E weighing >= 35kg\n Clients given 4E weighing >= 35kg\n \n 2022-06-30 13:25:02 UTC\n \n 2022-06-30 13:26: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 1643\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:25:02',4,'2022-06-30 15:26:56',4,0,NULL,NULL,NULL,'9f104324-88d3-4be9-8a9e-2535e4368371'),(1644,'Clients given 4K weighing 10-13.9kg','Clients given 4K weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 10-13.9kg\n Clients given 4K weighing 10-13.9kg\n \n 2022-06-30 13:25:05 UTC\n \n 2022-06-30 13:26: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 1644\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:25:05',4,'2022-06-30 15:26:01',4,0,NULL,NULL,NULL,'38fbaae4-791a-4bba-85ea-d149625c3d79'),(1645,'Clients given 4K weighing 14-19.9kg','Clients given 4K weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 14-19.9kg\n Clients given 4K weighing 14-19.9kg\n \n 2022-06-30 13:26:26 UTC\n \n 2022-06-30 13:27: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 1645\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:26:26',4,'2022-06-30 15:27:37',4,0,NULL,NULL,NULL,'c0be7036-edcf-4337-97d7-2bb22bc6ef54'),(1646,'Clients given 4F weighing 0-3.9kg','Clients given 4F weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 0-3.9kg\n Clients given 4F weighing 0-3.9kg\n \n 2022-06-30 13:26:29 UTC\n \n 2022-06-30 13:28: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 1646\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:26:29',4,'2022-06-30 15:28:31',4,0,NULL,NULL,NULL,'3df707cf-c633-4a85-ab9a-affe8619ca0e'),(1647,'Clients given 4K weighing 20-24.9kg','Clients given 4K weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 20-24.9kg\n Clients given 4K weighing 20-24.9kg\n \n 2022-06-30 13:26:52 UTC\n \n 2022-06-30 13:27: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 1647\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:26:52',4,'2022-06-30 15:27:51',4,0,NULL,NULL,NULL,'f1be8c70-bd5f-4b25-8703-ebc91a56a354'),(1648,'Clients given 4F weighing 4-5.9kg','Clients given 4F weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 4-5.9kg\n Clients given 4F weighing 4-5.9kg\n \n 2022-06-30 13:27:32 UTC\n \n 2022-06-30 13:28: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 1648\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:27:32',4,'2022-06-30 15:28:56',4,0,NULL,NULL,NULL,'651b9843-2f38-4e58-a87b-8d01b1e1b736'),(1649,'Clients given 4K weighing 25-34.9kg','Clients given 4K weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing 25-34.9kg\n Clients given 4K weighing 25-34.9kg\n \n 2022-06-30 13:28:20 UTC\n \n 2022-06-30 13:29: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 1649\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:28:20',4,'2022-06-30 15:29:38',4,0,NULL,NULL,NULL,'4a021424-b101-4001-8078-cd6e93935845'),(1650,'Clients given 4K weighing >=35kg','Clients given 4K weighing >=35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K weighing >=35kg\n Clients given 4K weighing >=35kg\n \n 2022-06-30 13:28:45 UTC\n \n 2022-06-30 13:29: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 1650\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:28:45',4,'2022-06-30 15:29:54',4,0,NULL,NULL,NULL,'86cffb6f-3533-48b5-a568-425a6d32e7e6'),(1651,'Clients given 4F weighing 6-9.9kg','Clients given 4F weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 6-9.9kg\n Clients given 4F weighing 6-9.9kg\n \n 2022-06-30 13:29:29 UTC\n \n 2022-06-30 13:33: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 1651\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:29:29',4,'2022-06-30 15:33:15',4,0,NULL,NULL,NULL,'0d1c19ab-8761-43c9-b362-a733800ce420'),(1652,'Clients given 4F weighing 10-13.9kg','Clients given 4F weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 10-13.9kg\n Clients given 4F weighing 10-13.9kg\n \n 2022-06-30 13:29:53 UTC\n \n 2022-06-30 13:31: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 1652\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:29:53',4,'2022-06-30 15:31:09',4,0,NULL,NULL,NULL,'0be49339-dac1-4872-9c6c-50fee86542d0'),(1653,'Clients given 4F weighing 14-19.9kg','Clients given 4F weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 14-19.9kg\n Clients given 4F weighing 14-19.9kg\n \n 2022-06-30 13:32:50 UTC\n \n 2022-06-30 13:34: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 1653\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:32:50',4,'2022-06-30 15:34:42',4,0,NULL,NULL,NULL,'10f82a49-a80e-4feb-8a54-5011945608bc'),(1654,'Clients given 4F weighing 20-24.9kg','Clients given 4F weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 20-24.9kg\n Clients given 4F weighing 20-24.9kg\n \n 2022-06-30 13:33:57 UTC\n \n 2022-06-30 13:35: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 1654\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:33:57',4,'2022-06-30 15:35:34',4,0,NULL,NULL,NULL,'1b492993-7168-4cee-aeae-ed3cb3136ef4'),(1655,'Clients given 4F weighing 25-34.9kg','Clients given 4F weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing 25-34.9kg\n Clients given 4F weighing 25-34.9kg\n \n 2022-06-30 13:35:56 UTC\n \n 2022-06-30 13:37: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 1655\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:35:56',4,'2022-06-30 15:37:26',4,0,NULL,NULL,NULL,'fd363f21-64f5-4465-8f1c-94a10ec790bc'),(1656,'Clients given 4F weighing >= 35kg','Clients given 4F weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F weighing >= 35kg\n Clients given 4F weighing >= 35kg\n \n 2022-06-30 13:36:27 UTC\n \n 2022-06-30 13:37: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 1656\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:36:27',4,'2022-06-30 15:37:46',4,0,NULL,NULL,NULL,'2ca64d93-82d9-40b9-ae24-669a1d529641'),(1657,'Clients given 4G weighing 0-3.9kg','Clients given 4G weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 0-3.9kg\n Clients given 4G weighing 0-3.9kg\n \n 2022-06-30 13:38:33 UTC\n \n 2022-06-30 13:39: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 1657\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:38:33',4,'2022-06-30 15:39:42',4,0,NULL,NULL,NULL,'e2b136d9-95a4-49fa-8069-476f5b7e1bc2'),(1658,'Clients given 4G weighing 4-5.9kg','Clients given 4G weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 4-5.9kg\n Clients given 4G weighing 4-5.9kg\n \n 2022-06-30 13:38:58 UTC\n \n 2022-06-30 13:40: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 1658\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:38:58',4,'2022-06-30 15:40:05',4,0,NULL,NULL,NULL,'dc8af817-8512-4a0a-b692-331377842479'),(1659,'Clients given 4G weighing 6-9.9kg','Clients given 4G weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 6-9.9kg\n Clients given 4G weighing 6-9.9kg\n \n 2022-06-30 13:40:27 UTC\n \n 2022-06-30 13:41: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 1659\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:40:27',4,'2022-06-30 15:41:40',4,0,NULL,NULL,NULL,'97f6acaa-3818-4efc-b6e0-8d8ecd3255b5'),(1660,'Clients given 4G weighing 10-13.9kg','Clients given 4G weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 10-13.9kg\n Clients given 4G weighing 10-13.9kg\n \n 2022-06-30 13:40:47 UTC\n \n 2022-06-30 13:43: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 1660\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:40:47',4,'2022-06-30 15:43:02',4,0,NULL,NULL,NULL,'ebcfa3fc-dea8-4a53-99f7-a16dc23a026c'),(1661,'Clients given 4G weighing 14-19.9kg','Clients given 4G weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 14-19.9kg\n Clients given 4G weighing 14-19.9kg\n \n 2022-06-30 13:42:19 UTC\n \n 2022-06-30 13:43: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 1661\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:42:19',4,'2022-06-30 15:43:59',4,0,NULL,NULL,NULL,'793e78bb-284c-47fa-8967-3fa124d3e9c7'),(1662,'Clients given 4G weighing 20-24.9kg','Clients given 4G weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 20-24.9kg\n Clients given 4G weighing 20-24.9kg\n \n 2022-06-30 13:43:37 UTC\n \n 2022-06-30 13:44: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 1662\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:43:37',4,'2022-06-30 15:44:44',4,0,NULL,NULL,NULL,'2bffd86c-c304-4fe5-bea0-dcba1ddacd30'),(1663,'Clients given 4G weighing 25-34.9kg','Clients given 4G weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing 25-34.9kg\n Clients given 4G weighing 25-34.9kg\n \n 2022-06-30 13:44:57 UTC\n \n 2022-06-30 13:48: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 1663\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:44:57',4,'2022-06-30 15:48:30',4,0,NULL,NULL,NULL,'dff299fd-70e4-42b6-821b-24bbfca5d130'),(1664,'Clients given 4G weighing >= 35kg','Clients given 4G weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G weighing >= 35kg\n Clients given 4G weighing >= 35kg\n \n 2022-06-30 13:45:24 UTC\n \n 2022-06-30 13:47: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 1664\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:45:24',4,'2022-06-30 15:47:50',4,0,NULL,NULL,NULL,'250554d7-b11e-4572-9fe8-191077c91497'),(1665,'Clients given 4H weighing 0-3.9kg','Clients given 4H weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 0-3.9kg\n Clients given 4H weighing 0-3.9kg\n \n 2022-06-30 13:49:48 UTC\n \n 2022-06-30 13:51: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 1665\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:49:48',4,'2022-06-30 15:51:33',4,0,NULL,NULL,NULL,'0681f349-aa2a-4030-8932-08fe50d977b7'),(1666,'Clients given 4H weighing 4-5.9kg','Clients given 4H weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 4-5.9kg\n Clients given 4H weighing 4-5.9kg\n \n 2022-06-30 13:50:26 UTC\n \n 2022-06-30 13:52: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 1666\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:50:26',4,'2022-06-30 15:52:13',4,0,NULL,NULL,NULL,'7d0948bd-e302-428d-be3e-c15ad93d5002'),(1667,'Clients given 4H weighing 6-9.9kg','Clients given 4H weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 6-9.9kg\n Clients given 4H weighing 6-9.9kg\n \n 2022-06-30 13:52:32 UTC\n \n 2022-06-30 13:53: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 1667\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:52:32',4,'2022-06-30 15:53:36',4,0,NULL,NULL,NULL,'ec54533d-f75a-4314-b085-4016edf73ccc'),(1668,'Clients given 4H weighing 10-13.9kg','Clients given 4H weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 10-13.9kg\n Clients given 4H weighing 10-13.9kg\n \n 2022-06-30 13:52:54 UTC\n \n 2022-06-30 13:53: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 1668\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:52:54',4,'2022-06-30 15:53:58',4,0,NULL,NULL,NULL,'306fc3f9-604f-4088-84fc-565bd360942d'),(1669,'Clients given 4H weighing 14-19.9kg','Clients given 4H weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 14-19.9kg\n Clients given 4H weighing 14-19.9kg\n \n 2022-06-30 13:54:20 UTC\n \n 2022-06-30 13:55: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 1669\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:54:20',4,'2022-06-30 15:55:40',4,0,NULL,NULL,NULL,'afa2260d-2d12-4922-8214-7321d1a7a0b2'),(1670,'Clients given 4H weighing 20-24.9kg','Clients given 4H weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 20-24.9kg\n Clients given 4H weighing 20-24.9kg\n \n 2022-06-30 13:54:47 UTC\n \n 2022-06-30 13: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 1670\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:54:47',4,'2022-06-30 15:56:07',4,0,NULL,NULL,NULL,'b12d0c96-1d85-4c87-8224-fcdcca3684ad'),(1671,'Clients given 4H weighing 25-34.9kg','Clients given 4H weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing 25-34.9kg\n Clients given 4H weighing 25-34.9kg\n \n 2022-06-30 13:56:49 UTC\n \n 2022-06-30 13: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 1671\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:56:49',4,'2022-06-30 15:59:24',4,0,NULL,NULL,NULL,'c03a3023-e223-4974-82d2-f9884b64fd94'),(1672,'Clients given 4H weighing >= 35kg','Clients given 4H weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing >= 35kg\n Clients given 4H weighing >= 35kg\n \n 2022-06-30 13:57:18 UTC\n \n 2022-06-30 13:59: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 1672\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 15:57:18',4,'2022-06-30 15:59:06',4,0,NULL,NULL,NULL,'021ba7c8-9dde-4912-850e-7e1f90746b9c'),(1673,'Clients given 4J weighing 0-3.9kg','Clients given 4J weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 0-3.9kg\n Clients given 4J weighing 0-3.9kg\n \n 2022-06-30 14:00:30 UTC\n \n 2022-06-30 14: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 1673\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:00:30',4,'2022-06-30 16:01:59',4,0,NULL,NULL,NULL,'21e22f99-3f2f-4e4a-ac19-ea6a1fe4030a'),(1674,'Clients given 4J weighing 4-5.9kg','Clients given 4J weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 4-5.9kg\n Clients given 4J weighing 4-5.9kg\n \n 2022-06-30 14:00:54 UTC\n \n 2022-06-30 14:02: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 1674\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:00:54',4,'2022-06-30 16:02:01',4,0,NULL,NULL,NULL,'14f446ec-5d3e-43b6-ad36-6153fe3ee3e9'),(1675,'Clients given 4J weighing 6-9.9kg','Clients given 4J weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 6-9.9kg\n Clients given 4J weighing 6-9.9kg\n \n 2022-06-30 14:03:04 UTC\n \n 2022-06-30 14:04: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 1675\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:03:04',4,'2022-06-30 16:04:17',4,0,NULL,NULL,NULL,'cc3db8f2-7644-426f-9c03-2a1d48ebd7d7'),(1676,'Clients given 4J weighing 10-13.9kg','Clients given 4J weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 10-13.9kg\n Clients given 4J weighing 10-13.9kg\n \n 2022-06-30 14:03:25 UTC\n \n 2022-06-30 14:04: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 1676\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:03:25',4,'2022-06-30 16:04:39',4,0,NULL,NULL,NULL,'adc9fdd3-0019-4213-998f-ab2d235aae80'),(1677,'Clients given 4J weighing 14-19.9kg','Clients given 4J weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 14-19.9kg\n Clients given 4J weighing 14-19.9kg\n \n 2022-06-30 14:05:01 UTC\n \n 2022-06-30 14: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 1677\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:05:01',4,'2022-06-30 16:06:13',4,0,NULL,NULL,NULL,'4fc6749f-c47b-4021-8dbf-26732df08880'),(1678,'Clients given 4J weighing 20-24.9kg','Clients given 4J weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 20-24.9kg\n Clients given 4J weighing 20-24.9kg\n \n 2022-06-30 14:05:23 UTC\n \n 2022-06-30 14:06: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 1678\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:05:23',4,'2022-06-30 16:06:34',4,0,NULL,NULL,NULL,'669e5746-1eee-4811-94dd-e4c6dd949131'),(1679,'Clients given 4J weighing 25-34.9kg','Clients given 4J weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing 25-34.9kg\n Clients given 4J weighing 25-34.9kg\n \n 2022-06-30 14:06:56 UTC\n \n 2022-06-30 14: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 1679\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:06:56',4,'2022-06-30 16:08:42',4,0,NULL,NULL,NULL,'78cbb142-b205-4059-89fa-70bd488a0513'),(1680,'Clients given 4J weighing >= 35kg','Clients given 4J weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing >= 35kg\n Clients given 4J weighing >= 35kg\n \n 2022-06-30 14:07:26 UTC\n \n 2022-06-30 14:09: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 1680\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:07:26',4,'2022-06-30 16:09:04',4,0,NULL,NULL,NULL,'ec90ccaa-999c-4b18-956b-50bee7c36868'),(1681,'Clients given 4L weighing 0-3.9kg','Clients given 4L weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 0-3.9kg\n Clients given 4L weighing 0-3.9kg\n \n 2022-06-30 14:09:37 UTC\n \n 2022-06-30 14:10: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 1681\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:09:37',4,'2022-06-30 16:10:48',4,0,NULL,NULL,NULL,'0e228ccb-1909-4a98-8334-89bf36d6e810'),(1682,'Clients given 4L weighing 4-5.9kg','Clients given 4L weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 4-5.9kg\n Clients given 4L weighing 4-5.9kg\n \n 2022-06-30 14:10:06 UTC\n \n 2022-06-30 14:11: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 1682\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:10:06',4,'2022-06-30 16:11:40',4,0,NULL,NULL,NULL,'d962f501-7157-4c19-9c7b-1a2a22053674'),(1683,'Clients given 4L weighing 6-9.9kg','Clients given 4L weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 6-9.9kg\n Clients given 4L weighing 6-9.9kg\n \n 2022-06-30 14:11:24 UTC\n \n 2022-06-30 14:13: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 1683\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:11:24',4,'2022-06-30 16:13:32',4,0,NULL,NULL,NULL,'16bb43f6-91a5-4e02-9627-9921460d5c68'),(1684,'Clients given 4L weighing 10-13.9kg','Clients given 4L weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 10-13.9kg\n Clients given 4L weighing 10-13.9kg\n \n 2022-06-30 14:12:51 UTC\n \n 2022-06-30 14:14: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 1684\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:12:51',4,'2022-06-30 16:14:24',4,0,NULL,NULL,NULL,'52d68e65-aa63-4c88-820e-e00bf66061ea'),(1685,'Clients given 4L weighing 14-19.9kg','Clients given 4L weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 14-19.9kg\n Clients given 4L weighing 14-19.9kg\n \n 2022-06-30 14:14:11 UTC\n \n 2022-06-30 14:15: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 1685\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:14:11',4,'2022-06-30 16:15:56',4,0,NULL,NULL,NULL,'1eb7fbd6-fa49-4ada-af7e-19424fb5a7e8'),(1686,'Clients given 4L weighing 20-24.9kg','Clients given 4L weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 20-24.9kg\n Clients given 4L weighing 20-24.9kg\n \n 2022-06-30 14:15:00 UTC\n \n 2022-06-30 14:16: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 1686\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:15:00',4,'2022-06-30 16:16:18',4,0,NULL,NULL,NULL,'d889b33a-5324-4655-965f-1fb6fdb8864d'),(1687,'Clients given 4L weighing 25-34.9kg','Clients given 4L weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing 25-34.9kg\n Clients given 4L weighing 25-34.9kg\n \n 2022-06-30 14:16:41 UTC\n \n 2022-06-30 14:18: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 1687\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:16:41',4,'2022-06-30 16:18:03',4,0,NULL,NULL,NULL,'f8853175-2a1a-4d34-9a40-2d9ae44b5367'),(1688,'Clients given 4L weighing >= 35kg','Clients given 4L weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing >= 35kg\n Clients given 4L weighing >= 35kg\n \n 2022-06-30 14:17:04 UTC\n \n 2022-06-30 14:18: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 1688\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-06-30 16:17:04',4,'2022-06-30 16:18:34',4,0,NULL,NULL,NULL,'6cf112ca-592d-4638-8919-561aeb0e1b2e'),(1689,'Clients given 5A weighing 0-3.9kg','Clients given 5A weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 0-3.9kg\n Clients given 5A weighing 0-3.9kg\n \n 2022-07-04 07:51:16 UTC\n \n 2022-07-04 07:59: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 1689\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 13:21:16',4,'2022-07-04 13:29:19',4,0,NULL,NULL,NULL,'1e8f892d-f7dd-4c03-bae2-2b6af9a96063'),(1690,'Clients given 5A weighing 4-5.9kg','Clients given 5A weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 4-5.9kg\n Clients given 5A weighing 4-5.9kg\n \n 2022-07-04 08:01:43 UTC\n \n 2022-07-04 08: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 1690\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 13:31:43',4,'2022-07-04 13:38:34',4,0,NULL,NULL,NULL,'caef996e-3278-49a5-a46b-264db7abba88'),(1691,'Clients given 5A weighing 6-9.9kg','Clients given 5A weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 6-9.9kg\n Clients given 5A weighing 6-9.9kg\n \n 2022-07-04 08:10:17 UTC\n \n 2022-07-04 08:27: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 1691\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 13:40:17',4,'2022-07-04 13:57:38',4,0,NULL,NULL,NULL,'e035adc0-696d-46e6-8075-9ea647aea054'),(1692,'Clients given 5A weighing 10-13.9kg','Clients given 5A weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 10-13.9kg\n Clients given 5A weighing 10-13.9kg\n \n 2022-07-04 08:12:41 UTC\n \n 2022-07-04 08:29: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 1692\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 13:42:41',4,'2022-07-04 13:59:01',4,0,NULL,NULL,NULL,'ee8edb07-58b9-4884-8044-948e6bdef0a8'),(1693,'Clients given 5A weighing 14-19.9kg','Clients given 5A weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 14-19.9kg\n Clients given 5A weighing 14-19.9kg\n \n 2022-07-04 08:15:22 UTC\n \n 2022-07-04 08:30: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 1693\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 13:45:22',4,'2022-07-04 14:00:32',4,0,NULL,NULL,NULL,'91a9fa6e-69dc-4980-bb69-ff2399a6e30e'),(1694,'Clients given 5A weighing 25-34.9kg','Clients given 5A weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 25-34.9kg\n Clients given 5A weighing 25-34.9kg\n \n 2022-07-04 08:17:38 UTC\n \n 2022-07-04 08:33: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 1694\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 13:47:38',4,'2022-07-04 14:03:14',4,0,NULL,NULL,NULL,'671c4577-cc93-464c-b822-cdbee99fce15'),(1695,'Clients given 5A weighing 20-24.9kg','Clients given 5A weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing 20-24.9kg\n Clients given 5A weighing 20-24.9kg\n \n 2022-07-04 08:21:33 UTC\n \n 2022-07-04 08:32: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 1695\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 13:51:33',4,'2022-07-04 14:02:01',4,0,NULL,NULL,NULL,'33f3931b-17d8-445a-8275-abe1c9c62e60'),(1696,'Clients given 5A weighing >= 35kg','Clients given 5A weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A weighing >= 35kg\n Clients given 5A weighing >= 35kg\n \n 2022-07-04 08:22:19 UTC\n \n 2022-07-04 08:25: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 1696\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 13:52:19',4,'2022-07-04 13:55:33',4,0,NULL,NULL,NULL,'4174b385-1353-40e8-8771-820e7b8cc439'),(1697,'Clients given 5B weighing 0-3.9kg','Clients given 5B weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 0-3.9kg\n Clients given 5B weighing 0-3.9kg\n \n 2022-07-04 08:35:49 UTC\n \n 2022-07-04 08:39: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 1697\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 14:05:49',4,'2022-07-04 14:09:51',4,0,NULL,NULL,NULL,'8ccf814e-72c3-40b9-8dae-53c47231713a'),(1698,'Clients given 5B weighing 4-5.9kg','Clients given 5B weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 4-5.9kg\n Clients given 5B weighing 4-5.9kg\n \n 2022-07-04 09:11:19 UTC\n \n 2022-07-04 09:12: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 1698\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 14:41:19',4,'2022-07-04 14:42:47',4,0,NULL,NULL,NULL,'da9d3384-9203-4c29-9bb3-0064275b0bbf'),(1699,'Clients given 5B weighing 6-9.9kg','Clients given 5B weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 6-9.9kg\n Clients given 5B weighing 6-9.9kg\n \n 2022-07-04 09:12:11 UTC\n \n 2022-07-04 09:14: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 1699\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 14:42:11',4,'2022-07-04 14:44:17',4,0,NULL,NULL,NULL,'9b461cbe-5394-43f1-a3a8-5cab077d880b'),(1700,'Clients given 5B weighing 10-13.9kg','Clients given 5B weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 10-13.9kg\n Clients given 5B weighing 10-13.9kg\n \n 2022-07-04 09:13:47 UTC\n \n 2022-07-04 09:15: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 1700\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 14:43:47',4,'2022-07-04 14:45:39',4,0,NULL,NULL,NULL,'e757de08-36b9-48aa-ae1c-6e8b67f41517'),(1701,'Clients given 5B weighing 14-19.9kg','Clients given 5B weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 14-19.9kg\n Clients given 5B weighing 14-19.9kg\n \n 2022-07-04 09:17:29 UTC\n \n 2022-07-04 09:33: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 1701\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 14:47:29',4,'2022-07-04 15:03:16',4,0,NULL,NULL,NULL,'b1164742-ca14-4264-979a-53f89a268f3a'),(1702,'Clients given 5B weighing 20-24.9kg','Clients given 5B weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 20-24.9kg\n Clients given 5B weighing 20-24.9kg\n \n 2022-07-04 09:18:14 UTC\n \n 2022-07-04 09: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 1702\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 14:48:14',4,'2022-07-04 15:03:55',4,0,NULL,NULL,NULL,'37598126-d94c-4da8-bbac-1e0b9020ef33'),(1703,'Clients given 5B weighing 25-34.9kg','Clients given 5B weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing 25-34.9kg\n Clients given 5B weighing 25-34.9kg\n \n 2022-07-04 09:38:26 UTC\n \n 2022-07-04 09:39: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 1703\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:08:26',4,'2022-07-04 15:09:35',4,0,NULL,NULL,NULL,'578575b5-5eaf-4487-85b6-e81f72e577e7'),(1704,'Clients given 5C weighing 0-3.9kg','Clients given 5C weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 0-3.9kg\n Clients given 5C weighing 0-3.9kg\n \n 2022-07-04 09:40:50 UTC\n \n 2022-07-04 09:46: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 1704\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:10:50',4,'2022-07-04 15:16:13',4,0,NULL,NULL,NULL,'183f7dbc-af84-4166-802d-fc168517be56'),(1705,'Clients given 5B weighing >= 35kg','Clients given 5B weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B weighing >= 35kg\n Clients given 5B weighing >= 35kg\n \n 2022-07-04 09:41:33 UTC\n \n 2022-07-04 09: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 1705\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:11:33',4,'2022-07-04 15:15:51',4,0,NULL,NULL,NULL,'bcad7f66-5905-4cb4-820c-20b76c185df0'),(1706,'Clients given 5C weighing 4-5.9kg','Clients given 5C weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 4-5.9kg\n Clients given 5C weighing 4-5.9kg\n \n 2022-07-04 09:46:54 UTC\n \n 2022-07-04 09:48: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 1706\n COUNT\n \n \n \n \n endDate\n ${startDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:16:54',4,'2022-07-04 15:18:55',4,0,NULL,NULL,NULL,'646d055c-d02e-46d9-8af4-e8edd67a053a'),(1707,'Clients given 5C weighing 6-9.9kg','Clients given 5C weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 6-9.9kg\n Clients given 5C weighing 6-9.9kg\n \n 2022-07-04 09:47:34 UTC\n \n 2022-07-04 09:49: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 1707\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:17:34',4,'2022-07-04 15:19:45',4,0,NULL,NULL,NULL,'bff00fe0-ccdd-4e59-8a04-5daae78f609f'),(1708,'Clients given 5C weighing 6-9.9kg','Clients given 5C weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 6-9.9kg\n Clients given 5C weighing 6-9.9kg\n \n 2022-07-04 09:50:21 UTC\n \n 2022-07-04 09: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 1708\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:20:21',4,'2022-07-04 15:22:53',4,0,NULL,NULL,NULL,'a12b3ec6-868f-49da-9993-65fcea6139ce'),(1709,'Clients given 5C weighing 10-13.9kg','Clients given 5C weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 10-13.9kg\n Clients given 5C weighing 10-13.9kg\n \n 2022-07-04 09:51:17 UTC\n \n 2022-07-04 09:54: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 1709\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:21:17',4,'2022-07-04 15:24:31',4,0,NULL,NULL,NULL,'11fd5caf-00b2-4c9b-89d3-dbe43460e1b4'),(1710,'Clients given 5C weighing 14-19.9kg','Clients given 5C weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 14-19.9kg\n Clients given 5C weighing 14-19.9kg\n \n 2022-07-04 09:54:02 UTC\n \n 2022-07-04 10:19: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 1710\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:24:02',4,'2022-07-04 15:49:24',4,0,NULL,NULL,NULL,'35c1a303-9f1d-41a4-a7b2-a63222c0c0f8'),(1711,'Clients given 5C weighing 20-24.9kg','Clients given 5C weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 20-24.9kg\n Clients given 5C weighing 20-24.9kg\n \n 2022-07-04 10:20:29 UTC\n \n 2022-07-04 10:24: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 1711\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:50:29',4,'2022-07-04 15:54:33',4,0,NULL,NULL,NULL,'300ad93a-8a96-42ee-b027-15e6ea66150c'),(1712,'Clients given 5C weighing 25-34.9kg','Clients given 5C weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing 25-34.9kg\n Clients given 5C weighing 25-34.9kg\n \n 2022-07-04 10:20:49 UTC\n \n 2022-07-04 10:23: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 1712\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:50:49',4,'2022-07-04 15:53:58',4,0,NULL,NULL,NULL,'2fb0cc71-47ac-4408-bb68-608d33609d53'),(1713,'Clients given 5C weighing >= 35kg','Clients given 5C weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C weighing >= 35kg\n Clients given 5C weighing >= 35kg\n \n 2022-07-04 10:26:20 UTC\n \n 2022-07-04 10:29: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 1713\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 15:56:20',4,'2022-07-04 15:59:43',4,0,NULL,NULL,NULL,'731fc698-2509-4d99-9163-e08624e75417'),(1714,'Clients given 5D weighing 0-3.9kg','Clients given 5D weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 0-3.9kg\n Clients given 5D weighing 0-3.9kg\n \n 2022-07-04 10:31:02 UTC\n \n 2022-07-04 10:34: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 1714\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:01:02',4,'2022-07-04 16:04:29',4,0,NULL,NULL,NULL,'b285d939-9f51-47bd-8a6d-7f4e5d321058'),(1715,'Clients given 5D weighing 4-5.9kg','Clients given 5D weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 4-5.9kg\n Clients given 5D weighing 4-5.9kg\n \n 2022-07-04 10:36:13 UTC\n \n 2022-07-04 10:38: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 1715\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:06:13',4,'2022-07-04 16:08:50',4,0,NULL,NULL,NULL,'8c7b5eac-d68a-4dbe-b341-3417d6c7cb50'),(1716,'Clients given 5D weighing 6-9.9kg','Clients given 5D weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 6-9.9kg\n Clients given 5D weighing 6-9.9kg\n \n 2022-07-04 10:36:38 UTC\n \n 2022-07-04 10:38: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 1716\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:06:38',4,'2022-07-04 16:08:25',4,0,NULL,NULL,NULL,'f1dbcf85-e7e2-406e-ab4f-5b29a0f2dfb3'),(1717,'Clients given 5D weighing 10-13.9kg','Clients given 5D weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 10-13.9kg\n Clients given 5D weighing 10-13.9kg\n \n 2022-07-04 10:39:56 UTC\n \n 2022-07-04 10: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 1717\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:09:56',4,'2022-07-04 16:12:05',4,0,NULL,NULL,NULL,'cc9e92c9-53f2-46a4-be46-ca904d385286'),(1718,'Clients given 5D weighing 14-19.9kg','Clients given 5D weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 14-19.9kg\n Clients given 5D weighing 14-19.9kg\n \n 2022-07-04 10:40:24 UTC\n \n 2022-07-04 10:42: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 1718\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:10:24',4,'2022-07-04 16:12:36',4,0,NULL,NULL,NULL,'ea3aa469-cc4f-499c-b20f-a163afa5c116'),(1719,'Clients given 5D weighing 20-24.9kg','Clients given 5D weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 20-24.9kg\n Clients given 5D weighing 20-24.9kg\n \n 2022-07-04 10:43:39 UTC\n \n 2022-07-04 10:45: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 1719\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:13:39',4,'2022-07-04 16:15:07',4,0,NULL,NULL,NULL,'51201bc9-2e68-47b2-a264-dfe852767cbb'),(1720,'Clients given 5D weighing 25-34.9kg','Clients given 5D weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing 25-34.9kg\n Clients given 5D weighing 25-34.9kg\n \n 2022-07-04 10:44:10 UTC\n \n 2022-07-04 10:46: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 1720\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:14:10',4,'2022-07-04 16:16:49',4,0,NULL,NULL,NULL,'99779a0a-4228-4d21-bc53-a4724c950f64'),(1721,'Clients given 5D weighing >= 35kg','Clients given 5D weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D weighing >= 35kg\n Clients given 5D weighing >= 35kg\n \n 2022-07-04 10:46:20 UTC\n \n 2022-07-04 10:49: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 1721\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:16:20',4,'2022-07-04 16:19:12',4,0,NULL,NULL,NULL,'a9db689b-55c9-49a6-bf7b-f841503b81d4'),(1722,'Clients given 5E weighing 0-3.9kg','Clients given 5E weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 0-3.9kg\n Clients given 5E weighing 0-3.9kg\n \n 2022-07-04 10:49:03 UTC\n \n 2022-07-04 10: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 1722\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:19:03',4,'2022-07-04 16:24:57',4,0,NULL,NULL,NULL,'98825a71-acf0-4a06-b318-1dfbc4bc85e8'),(1723,'Clients given 5E weighing 4-5.9kg','Clients given 5E weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 4-5.9kg\n Clients given 5E weighing 4-5.9kg\n \n 2022-07-04 10:50:24 UTC\n \n 2022-07-04 10: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 1723\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:20:24',4,'2022-07-04 16:23:38',4,0,NULL,NULL,NULL,'09876d38-7d00-460f-a95d-f1d084f84cb0'),(1724,'Clients given 5E weighing 6-9.9kg','Clients given 5E weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 6-9.9kg\n Clients given 5E weighing 6-9.9kg\n \n 2022-07-04 10:55:45 UTC\n \n 2022-07-04 10:59: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 1724\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:25:45',4,'2022-07-04 16:29:01',4,0,NULL,NULL,NULL,'d95839a2-da76-4d9f-9dde-6ef33f9d3c7d'),(1725,'Clients given 5E weighing 10-13.9kg','Clients given 5E weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 10-13.9kg\n Clients given 5E weighing 10-13.9kg\n \n 2022-07-04 10:56:27 UTC\n \n 2022-07-04 11:04: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 1725\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:26:27',4,'2022-07-04 16:34:36',4,0,NULL,NULL,NULL,'c0a9a74f-b14c-42fb-87bc-710bd652916c'),(1726,'Clients given 5E weighing 14-19.9kg','Clients given 5E weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 14-19.9kg\n Clients given 5E weighing 14-19.9kg\n \n 2022-07-04 11:00:36 UTC\n \n 2022-07-04 11:07: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 1726\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:30:36',4,'2022-07-04 16:37:08',4,0,NULL,NULL,NULL,'29478b1e-23c8-4fa0-a17e-9f3c11e801af'),(1727,'Clients given 5E weighing 20-24.9kg','Clients given 5E weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 20-24.9kg\n Clients given 5E weighing 20-24.9kg\n \n 2022-07-04 11:06:35 UTC\n \n 2022-07-04 11:08: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 1727\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:36:35',4,'2022-07-04 16:38:57',4,0,NULL,NULL,NULL,'0a71c7f2-39c8-4d46-bdb3-847b616997b6'),(1728,'Clients given 5E weighing 25-34.9kg','Clients given 5E weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing 25-34.9kg\n Clients given 5E weighing 25-34.9kg\n \n 2022-07-04 11:09:38 UTC\n \n 2022-07-04 11:12: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 1728\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:39:38',4,'2022-07-04 16:42:02',4,0,NULL,NULL,NULL,'f20e7d1a-0f66-4fb8-a254-11720f9fcdb4'),(1729,'Clients given 5E weighing >= 35kg','Clients given 5E weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E weighing >= 35kg\n Clients given 5E weighing >= 35kg\n \n 2022-07-04 11:10:10 UTC\n \n 2022-07-04 11:11: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 1729\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:40:10',4,'2022-07-04 16:41:28',4,0,NULL,NULL,NULL,'6c8300f9-3327-46f5-b538-5926daf7f3e9'),(1730,'Clients given 5F weighing 0-3.9kg','Clients given 5F weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 0-3.9kg\n Clients given 5F weighing 0-3.9kg\n \n 2022-07-04 11:12:43 UTC\n \n 2022-07-04 11:16: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 1730\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:42:43',4,'2022-07-04 16:46:11',4,0,NULL,NULL,NULL,'cc140697-6404-4bfa-927a-1e331e05a771'),(1731,'Clients given 5F weighing 4-5.9kg','Clients given 5F weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 4-5.9kg\n Clients given 5F weighing 4-5.9kg\n \n 2022-07-04 11:15:42 UTC\n \n 2022-07-04 11: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 1731\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:45:42',4,'2022-07-04 16:47:37',4,0,NULL,NULL,NULL,'feee080e-df6e-4d55-a631-a5b8e6561be8'),(1732,'Clients given 5F weighing 6-9.9kg','Clients given 5F weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 6-9.9kg\n Clients given 5F weighing 6-9.9kg\n \n 2022-07-04 11:16:51 UTC\n \n 2022-07-04 11:20: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 1732\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:46:51',4,'2022-07-04 16:50:54',4,0,NULL,NULL,NULL,'fefc7c1d-f181-415a-b896-9ef303b4ce6a'),(1733,'Clients given 5F weighing 10-13.9kg','Clients given 5F weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 10-13.9kg\n Clients given 5F weighing 10-13.9kg\n \n 2022-07-04 11:19:35 UTC\n \n 2022-07-04 11:21: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 1733\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:49:35',4,'2022-07-04 16:51:36',4,0,NULL,NULL,NULL,'cc52bd93-49e7-488c-9706-669f6401eb7a'),(1734,'Clients given 5F weighing 14-19.9kg','Clients given 5F weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 14-19.9kg\n Clients given 5F weighing 14-19.9kg\n \n 2022-07-04 11:27:47 UTC\n \n 2022-07-04 11:30: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 1734\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:57:47',4,'2022-07-04 17:00:51',4,0,NULL,NULL,NULL,'a1b3f036-8f11-463c-906f-0907c8bb3168'),(1735,'Clients given 5F weighing 20-24.9kg','Clients given 5F weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 20-24.9kg\n Clients given 5F weighing 20-24.9kg\n \n 2022-07-04 11:28:06 UTC\n \n 2022-07-04 11:31: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 1735\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 16:58:06',4,'2022-07-04 17:01:26',4,0,NULL,NULL,NULL,'545d0307-0065-48ef-b35d-db0b97d6f0a4'),(1736,'Clients given 5F weighing 25-34.9kg','Clients given 5F weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing 25-34.9kg\n Clients given 5F weighing 25-34.9kg\n \n 2022-07-04 11:32:18 UTC\n \n 2022-07-04 11:34: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 1736\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:02:18',4,'2022-07-04 17:04:20',4,0,NULL,NULL,NULL,'a3cc0250-e3f5-4b02-a569-d5737c7c2ca2'),(1737,'Clients given 5F weighing >= 35kg','Clients given 5F weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F weighing >= 35kg\n Clients given 5F weighing >= 35kg\n \n 2022-07-04 11:32:59 UTC\n \n 2022-07-04 11:34: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 1737\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:02:59',4,'2022-07-04 17:04:45',4,0,NULL,NULL,NULL,'ff867f63-d45f-4ffc-8378-22a72111492b'),(1738,'Clients given 5G weighing 0-3.9kg','Clients given 5G weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 0-3.9kg\n Clients given 5G weighing 0-3.9kg\n \n 2022-07-04 11:37:11 UTC\n \n 2022-07-04 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 1738\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:07:11',4,'2022-07-04 17:09:08',4,0,NULL,NULL,NULL,'b5725eac-2a7a-4f4b-be0b-670c5edae46f'),(1739,'Clients given 5G weighing 4-5.9kg','Clients given 5G weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 4-5.9kg\n Clients given 5G weighing 4-5.9kg\n \n 2022-07-04 11:38:21 UTC\n \n 2022-07-04 11:40: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 1739\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:08:21',4,'2022-07-04 17:10:28',4,0,NULL,NULL,NULL,'01b5a831-a97a-473d-9cab-171aed11937a'),(1740,'Clients given 5G weighing 6-9.9kg','Clients given 5G weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 6-9.9kg\n Clients given 5G weighing 6-9.9kg\n \n 2022-07-04 11:40:56 UTC\n \n 2022-07-04 11:42: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 1740\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:10:56',4,'2022-07-04 17:12:46',4,0,NULL,NULL,NULL,'b35556af-d5de-4740-8d7d-ee2c7415f2aa'),(1741,'Clients given 5G weighing 10-13.9kg','Clients given 5G weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 10-13.9kg\n Clients given 5G weighing 10-13.9kg\n \n 2022-07-04 11:41:26 UTC\n \n 2022-07-04 11:43: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 1741\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:11:26',4,'2022-07-04 17:13:31',4,0,NULL,NULL,NULL,'fecb7060-8111-4db9-aa13-9355bfe19034'),(1742,'Clients given 5G weighing 14-19.9kg','Clients given 5G weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 14-19.9kg\n Clients given 5G weighing 14-19.9kg\n \n 2022-07-04 11:44:52 UTC\n \n 2022-07-04 11:47: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 1742\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:14:52',4,'2022-07-04 17:17:38',4,0,NULL,NULL,NULL,'edcea1e9-f4fe-459c-a9a5-99dc5b454f6b'),(1743,'Clients given 5G weighing 20-24.9kg','Clients given 5G weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 20-24.9kg\n Clients given 5G weighing 20-24.9kg\n \n 2022-07-04 11:45:28 UTC\n \n 2022-07-04 11:47: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 1743\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:15:28',4,'2022-07-04 17:17:23',4,0,NULL,NULL,NULL,'d624256f-ee53-49de-b806-e54f0f885165'),(1744,'Clients given 5G weighing 25-34.9kg','Clients given 5G weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 25-34.9kg\n Clients given 5G weighing 25-34.9kg\n \n 2022-07-04 11:48:46 UTC\n \n 2022-07-06 09:16: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 1744\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 11:48:46',4,'2022-07-06 09:16:23',4,0,NULL,NULL,NULL,'2fdbe8de-90ef-4198-8960-6d195608e255'),(1745,'Clients given 5G weighing >= 35kg','Clients given 5G weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing >= 35kg\n Clients given 5G weighing >= 35kg\n \n 2022-07-04 11:49:49 UTC\n \n 2022-07-04 11:51: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 1745\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:19:49',4,'2022-07-04 17:21:52',4,0,NULL,NULL,NULL,'477dc5ab-12a7-4553-b65d-57ced1093ae7'),(1746,'Clients given 5G weighing 0-3.9kg','Clients given 5G weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 0-3.9kg\n Clients given 5G weighing 0-3.9kg\n \n 2022-07-04 11:52:26 UTC\n \n 2022-07-04 11:55: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 1746\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:22:26',4,'2022-07-04 17:25:43',4,0,NULL,NULL,NULL,'b30dd237-ce5e-4eb4-8c3e-e4522f1fc695'),(1747,'Clients given 5G weighing 4-5.9kg','Clients given 5G weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 4-5.9kg\n Clients given 5G weighing 4-5.9kg\n \n 2022-07-04 11:53:47 UTC\n \n 2022-07-04 11:56: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 1747\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:23:47',4,'2022-07-04 17:26:37',4,0,NULL,NULL,NULL,'8e235e40-e811-4db9-82c2-ab1b5d2965f9'),(1748,'Clients given 5G weighing 6-9.9kg','Clients given 5G weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 6-9.9kg\n Clients given 5G weighing 6-9.9kg\n \n 2022-07-04 11:57:59 UTC\n \n 2022-07-04 12: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 1748\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:27:59',4,'2022-07-04 17:30:12',4,0,NULL,NULL,NULL,'b0a0a091-97ba-49d0-9845-f10070dd4ea3'),(1749,'Clients given 5G weighing 10-13.9kg','Clients given 5G weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 10-13.9kg\n Clients given 5G weighing 10-13.9kg\n \n 2022-07-04 11:58:53 UTC\n \n 2022-07-04 12:00: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 1749\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:28:53',4,'2022-07-04 17:30:48',4,0,NULL,NULL,NULL,'3d826ce1-96c8-4e57-892d-c097e4ac9ac5'),(1750,'Clients given 5G weighing 14-19.9kg','Clients given 5G weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 14-19.9kg\n Clients given 5G weighing 14-19.9kg\n \n 2022-07-04 12:03:51 UTC\n \n 2022-07-04 12:08: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 1750\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:33:51',4,'2022-07-04 17:38:23',4,0,NULL,NULL,NULL,'79890495-f468-4d64-b519-756630352b5d'),(1751,'Clients given 5G weighing 20-24.9kg','Clients given 5G weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 20-24.9kg\n Clients given 5G weighing 20-24.9kg\n \n 2022-07-04 12:04:50 UTC\n \n 2022-07-04 18:39: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 1751\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-04 17:34:50',4,'2022-07-05 00:09:28',4,0,NULL,NULL,NULL,'d06ae952-edbf-4c3e-b3a8-1c4ee70886fc'),(1752,' Clients given 5G weighing 25-29.9kg',' Clients given 5G weighing 25-29.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing 25-29.9kg\n Clients given 5G weighing 25-29.9kg\n \n 2022-07-04 18:44:18 UTC\n \n 2022-07-04 18:47: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 1752\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:14:18',4,'2022-07-05 00:17:20',4,0,NULL,NULL,NULL,'ad3c3764-3438-43a7-ade5-98458af16de5'),(1753,' Clients given 5G weighing >= 35kg',' Clients given 5G weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G weighing >= 35kg\n Clients given 5G weighing >= 35kg\n \n 2022-07-04 18:47:57 UTC\n \n 2022-07-04 18:49: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 1753\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:17:57',4,'2022-07-05 00:19:45',4,0,NULL,NULL,NULL,'5c731dbc-ddd2-4a58-9e69-c112f74d40a7'),(1754,' Clients given 5H weighing 0-3.9kg',' Clients given 5H weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 0-3.9kg\n Clients given 5H weighing 0-3.9kg\n \n 2022-07-04 18:49:18 UTC\n \n 2022-07-04 18:53: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 1754\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:19:18',4,'2022-07-05 00:23:27',4,0,NULL,NULL,NULL,'76ca732d-65f9-4ec3-8c5c-41d7503ed512'),(1755,' Clients given 5H weighing 4-5.9kg',' Clients given 5H weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 4-5.9kg\n Clients given 5H weighing 4-5.9kg\n \n 2022-07-04 18:54:29 UTC\n \n 2022-07-04 18:55: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 1755\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:24:29',4,'2022-07-05 00:25:53',4,0,NULL,NULL,NULL,'75354bc7-40ec-489e-a13a-5b0de9d609cd'),(1756,' Clients given 5H weighing 6-9.9kg',' Clients given 5H weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 6-9.9kg\n Clients given 5H weighing 6-9.9kg\n \n 2022-07-04 18:55:07 UTC\n \n 2022-07-04 18: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 1756\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:25:07',4,'2022-07-05 00:28:07',4,0,NULL,NULL,NULL,'4c27c57e-78ec-4934-837f-d52f59a8e263'),(1757,' Clients given 5H weighing 10-13.9kg',' Clients given 5H weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 10-13.9kg\n Clients given 5H weighing 10-13.9kg\n \n 2022-07-04 18:57:10 UTC\n \n 2022-07-04 19:05: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 1757\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:27:10',4,'2022-07-05 00:35:15',4,0,NULL,NULL,NULL,'10ee2cc4-a8c0-46c7-8b26-2c69eafd6aed'),(1758,' Clients given 5H weighing 14-19.9kg',' Clients given 5H weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 14-19.9kg\n Clients given 5H weighing 14-19.9kg\n \n 2022-07-04 18:58:51 UTC\n \n 2022-07-04 19:01: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 1758\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:28:51',4,'2022-07-05 00:31:57',4,0,NULL,NULL,NULL,'bfd4191f-c556-41df-8f09-970ece8eb883'),(1759,' Clients given 5H weighing 20-24.9kg',' Clients given 5H weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 20-24.9kg\n Clients given 5H weighing 20-24.9kg\n \n 2022-07-04 19:02:44 UTC\n \n 2022-07-04 19:03: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 1759\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:32:44',4,'2022-07-05 00:33:54',4,0,NULL,NULL,NULL,'3118f852-4fd1-4807-abfc-6f4d8a4b34e3'),(1760,' Clients given 5H weighing 25-34.9kg',' Clients given 5H weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing 25-34.9kg\n Clients given 5H weighing 25-34.9kg\n \n 2022-07-04 19:04:45 UTC\n \n 2022-07-04 19:07: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 1760\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:34:45',4,'2022-07-05 00:37:04',4,0,NULL,NULL,NULL,'443efbd3-a0a9-473a-8408-e57b58477156'),(1761,' Clients given 5H weighing >= 35kg',' Clients given 5H weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H weighing >= 35kg\n Clients given 5H weighing >= 35kg\n \n 2022-07-04 19:06:06 UTC\n \n 2022-07-04 19:07: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 1761\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:36:06',4,'2022-07-05 00:37:27',4,0,NULL,NULL,NULL,'89320a1f-49b4-464e-8a37-21748419ed81'),(1762,' Clients given 6A weighing 0-3.9kg',' Clients given 6A weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 0-3.9kg\n Clients given 6A weighing 0-3.9kg\n \n 2022-07-04 19:08:02 UTC\n \n 2022-07-04 19:09: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 1762\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:38:02',4,'2022-07-05 00:39:31',4,0,NULL,NULL,NULL,'f0cdda8e-9894-4125-b1c0-014ccc6ad7ea'),(1763,' Clients given 6A weighing 4-5.9kg',' Clients given 6A weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 4-5.9kg\n Clients given 6A weighing 4-5.9kg\n \n 2022-07-04 19:08:26 UTC\n \n 2022-07-04 19:09: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 1763\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:38:26',4,'2022-07-05 00:39:50',4,0,NULL,NULL,NULL,'5701682a-a88c-46a8-957a-3322894a6e43'),(1764,' Clients given 6A weighing 6-9.9kg',' Clients given 6A weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 6-9.9kg\n Clients given 6A weighing 6-9.9kg\n \n 2022-07-04 19:10:14 UTC\n \n 2022-07-04 19:11: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 1764\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:40:14',4,'2022-07-05 00:41:50',4,0,NULL,NULL,NULL,'92f27e6f-6178-4e65-b055-798f3dd1e1ae'),(1765,' Clients given 6A weighing 10-13.9kg',' Clients given 6A weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 10-13.9kg\n Clients given 6A weighing 10-13.9kg\n \n 2022-07-04 19:10:49 UTC\n \n 2022-07-04 19:12: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 1765\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:40:49',4,'2022-07-05 00:42:19',4,0,NULL,NULL,NULL,'a74e222c-96c6-45f8-83e7-3ce0d50cc83c'),(1766,' Clients given 6A weighing 14-19.9kg',' Clients given 6A weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 14-19.9kg\n Clients given 6A weighing 14-19.9kg\n \n 2022-07-04 19:12:45 UTC\n \n 2022-07-04 19:14: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 1766\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:42:45',4,'2022-07-05 00:44:57',4,0,NULL,NULL,NULL,'79e9b5db-636c-4afb-8291-cb558667ebd5'),(1767,' Clients given 6A weighing 20-24.9kg',' Clients given 6A weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 20-24.9kg\n Clients given 6A weighing 20-24.9kg\n \n 2022-07-04 19:13:20 UTC\n \n 2022-07-04 19:15: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 1767\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:43:20',4,'2022-07-05 00:45:14',4,0,NULL,NULL,NULL,'11eeec05-8a04-4f44-bc0c-dddb88b8270d'),(1768,' Clients given 6A weighing 25-34.9kg',' Clients given 6A weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing 25-34.9kg\n Clients given 6A weighing 25-34.9kg\n \n 2022-07-04 19:13:46 UTC\n \n 2022-07-04 19:15: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 1768\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:43:46',4,'2022-07-05 00:45:35',4,0,NULL,NULL,NULL,'23c30258-a527-4c1e-92b8-c3d7310c7c49'),(1769,' Clients given 6A weighing >= 35kg',' Clients given 6A weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A weighing >= 35kg\n Clients given 6A weighing >= 35kg\n \n 2022-07-04 19:16:05 UTC\n \n 2022-07-04 19:18: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 1769\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:46:05',4,'2022-07-05 00:48:21',4,0,NULL,NULL,NULL,'eac739c5-ff7a-4169-a6c2-faba753958df'),(1770,' Clients given 6B weighing 0-3.9kg',' Clients given 6B weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 0-3.9kg\n Clients given 6B weighing 0-3.9kg\n \n 2022-07-04 19:16:33 UTC\n \n 2022-07-04 19: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 1770\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:46:33',4,'2022-07-05 00:48:05',4,0,NULL,NULL,NULL,'6e8cb9ab-5663-4da1-9c67-9188bf5ce4c6'),(1771,' Clients given 6B weighing 4-5.9kg',' Clients given 6B weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 4-5.9kg\n Clients given 6B weighing 4-5.9kg\n \n 2022-07-04 19:16:56 UTC\n \n 2022-07-04 19:18: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 1771\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:46:56',4,'2022-07-05 00:48:41',4,0,NULL,NULL,NULL,'6e7f8b89-d2bb-42a4-8b0d-687950bfd3a8'),(1772,' Clients given 6B weighing 6-9.9kg',' Clients given 6B weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 6-9.9kg\n Clients given 6B weighing 6-9.9kg\n \n 2022-07-04 19:19:08 UTC\n \n 2022-07-04 19:22: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 1772\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:49:08',4,'2022-07-05 00:52:03',4,0,NULL,NULL,NULL,'4ccea0f3-80d7-4b3f-850f-93985538cfeb'),(1773,' Clients given 6B weighing 10-13.9kg',' Clients given 6B weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 10-13.9kg\n Clients given 6B weighing 10-13.9kg\n \n 2022-07-04 19:19:37 UTC\n \n 2022-07-04 19:22: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 1773\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:49:37',4,'2022-07-05 00:52:18',4,0,NULL,NULL,NULL,'3c303fcf-f9db-4e5f-8e9e-33df86616930'),(1774,' Clients given 6B weighing 14-19.9kg',' Clients given 6B weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 14-19.9kg\n Clients given 6B weighing 14-19.9kg\n \n 2022-07-04 19:20:09 UTC\n \n 2022-07-04 19: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 1774\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:50:09',4,'2022-07-05 00:54:44',4,0,NULL,NULL,NULL,'551ea342-168d-4089-834b-dab745648722'),(1775,' Clients given 6B weighing 20-24.9kg',' Clients given 6B weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 20-24.9kg\n Clients given 6B weighing 20-24.9kg\n \n 2022-07-04 19:20:32 UTC\n \n 2022-07-04 19:23: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 1775\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:50:32',4,'2022-07-05 00:53:03',4,0,NULL,NULL,NULL,'42e304a1-3961-4344-ae32-2348b7a5b81a'),(1776,' Clients given 6B weighing 25-34.9kg',' Clients given 6B weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing 25-34.9kg\n Clients given 6B weighing 25-34.9kg\n \n 2022-07-04 19:23:47 UTC\n \n 2022-07-04 19:27: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 1776\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:53:47',4,'2022-07-05 00:57:17',4,0,NULL,NULL,NULL,'70621294-d632-4b66-8f10-0343433b8267'),(1777,' Clients given 6B weighing >= 35kg',' Clients given 6B weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B weighing >= 35kg\n Clients given 6B weighing >= 35kg\n \n 2022-07-04 19:24:19 UTC\n \n 2022-07-04 19:27: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 1777\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 00:54:19',4,'2022-07-05 00:57:33',4,0,NULL,NULL,NULL,'ed32ff5b-41ed-4933-a39e-bc4fb685b9eb'),(1778,'Clients given 6C weighing 0-3.9kg','Clients given 6C weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 0-3.9kg\n Clients given 6C weighing 0-3.9kg\n \n 2022-07-05 06:03:11 UTC\n \n 2022-07-05 06:05: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 1778\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:33:11',4,'2022-07-05 11:35:26',4,0,NULL,NULL,NULL,'7708c697-6d7d-42e7-aba6-613e36081fab'),(1779,'Clients given 6C weighing 4-5.9kg','Clients given 6C weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 4-5.9kg\n Clients given 6C weighing 6-9.9kg\n \n 2022-07-05 06:03:33 UTC\n \n 2022-07-05 06:09: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 1779\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:33:33',4,'2022-07-05 11:39:04',4,0,NULL,NULL,NULL,'95504660-becd-4eff-a280-5aa869762885'),(1780,'Clients given 6C weighing 6-9.9kg','Clients given 6C weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 6-9.9kg\n Clients given 6C weighing 6-9.9kg\n \n 2022-07-05 06:03:55 UTC\n \n 2022-07-05 06:07: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 1780\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:33:55',4,'2022-07-05 11:37:47',4,0,NULL,NULL,NULL,'d3ba1e90-03ce-4af3-8b68-9e4bb86a2fda'),(1781,'Clients given 6C weighing 10-13.9kg','Clients given 6C weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 10-13.9kg\n Clients given 6C weighing 10-13.9kg\n \n 2022-07-05 06:09:31 UTC\n \n 2022-07-05 06:12:33 UTC\n \n \n location\n \n org.openmrs.Location\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n 1781\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:39:31',4,'2022-07-05 11:42:33',4,0,NULL,NULL,NULL,'bd61f262-344c-4834-846b-dbfd4b8f8454'),(1782,'Clients given 6C weighing 14-19.9kg','Clients given 6C weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 14-19.9kg\n Clients given 6C weighing 14-19.9kg\n \n 2022-07-05 06:11:03 UTC\n \n 2022-07-05 06: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 1782\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:41:03',4,'2022-07-05 11:44:18',4,0,NULL,NULL,NULL,'ef452600-16ec-4d05-bf02-a2f5da8c503d'),(1783,'Clients given 6C weighing 20-24.9kg','Clients given 6C weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 20-24.9kg\n Clients given 6C weighing 20-24.9kg\n \n 2022-07-05 06:12:09 UTC\n \n 2022-07-05 06:14: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 1783\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:42:09',4,'2022-07-05 11:44:44',4,0,NULL,NULL,NULL,'84b7e946-ef4b-498c-aa99-a7469d841d89'),(1784,'Clients given 6C weighing 25-34.9kg','Clients given 6C weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing 25-34.9kg\n Clients given 6C weighing 25-34.9kg\n \n 2022-07-05 06:13:57 UTC\n \n 2022-07-05 06: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 1784\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:43:57',4,'2022-07-05 11:47:03',4,0,NULL,NULL,NULL,'d0662ec5-9909-46a1-8d42-4f13c5e08f54'),(1785,'Clients given 6C weighing >= 35kg','Clients given 6C weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C weighing >= 35kg\n Clients given 6C weighing >= 35kg\n \n 2022-07-05 06:17:43 UTC\n \n 2022-07-05 06:20: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 1785\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:47:43',4,'2022-07-05 11:50:43',4,0,NULL,NULL,NULL,'e469295b-caa7-4154-b5ac-e2d0a7042d5b'),(1786,'Clients given 6D weighing 0-3.9kg','Clients given 6D weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 0-3.9kg\n Clients given 6D weighing 0-3.9kg\n \n 2022-07-05 06:18:16 UTC\n \n 2022-07-05 06:19: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 1786\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:48:16',4,'2022-07-05 11:49:53',4,0,NULL,NULL,NULL,'a6985c5b-86f8-4647-86ea-ddd69097681e'),(1787,'Clients given 6D weighing 4-5.9kg','Clients given 6D weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 4-5.9kg\n Clients given 6D weighing 4-5.9kg\n \n 2022-07-05 06:18:43 UTC\n \n 2022-07-05 06:20: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 1787\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:48:43',4,'2022-07-05 11:50:24',4,0,NULL,NULL,NULL,'3eec1d07-6d91-43dd-a942-24d23e4a0f9c'),(1788,'Clients given 6D weighing 6-9.9kg','Clients given 6D weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 6-9.9kg\n Clients given 6D weighing 6-9.9kg\n \n 2022-07-05 06:21:17 UTC\n \n 2022-07-05 06:22: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 1788\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:51:17',4,'2022-07-05 11:52:45',4,0,NULL,NULL,NULL,'37509f55-cbd9-4096-8522-1e7918b1a48c'),(1789,'Clients given 6D weighing 10-13.9kg','Clients given 6D weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 10-13.9kg\n Clients given 6D weighing 10-13.9kg\n \n 2022-07-05 06:21:34 UTC\n \n 2022-07-05 06:23: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 1789\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:51:34',4,'2022-07-05 11:53:04',4,0,NULL,NULL,NULL,'477311cf-0367-47e1-9717-4732fc0752f0'),(1790,'Clients given 6D weighing 14-19.9kg','Clients given 6D weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 14-19.9kg\n Clients given 6D weighing 14-19.9kg\n \n 2022-07-05 06:21:55 UTC\n \n 2022-07-05 06: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 1790\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:51:55',4,'2022-07-05 11:53:21',4,0,NULL,NULL,NULL,'62232334-aa48-4e29-92fc-c4f931bcfb01'),(1791,'Clients given 6D weighing 20-24.9kg','Clients given 6D weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 20-24.9kg\n Clients given 6D weighing 20-24.9kg\n \n 2022-07-05 06:23:43 UTC\n \n 2022-07-05 06:25: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 1791\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:53:43',4,'2022-07-05 11:55:33',4,0,NULL,NULL,NULL,'8b171cf1-4052-49f3-9b28-76161872f1ac'),(1792,'Clients given 6D weighing 25-34.9kg','Clients given 6D weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing 25-34.9kg\n Clients given 6D weighing 25-34.9kg\n \n 2022-07-05 06:24:03 UTC\n \n 2022-07-05 06:25: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 1792\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:54:03',4,'2022-07-05 11:55:47',4,0,NULL,NULL,NULL,'20d6a8c0-12ee-420c-a3f6-22d2e7a829bd'),(1793,'Clients given 6D weighing >= 35kg','Clients given 6D weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D weighing >= 35kg\n Clients given 6D weighing >= 35kg\n \n 2022-07-05 06:24:35 UTC\n \n 2022-07-05 06:26: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 1793\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:54:35',4,'2022-07-05 11:56:11',4,0,NULL,NULL,NULL,'41d104fe-8277-4caa-b55e-07ea346801a7'),(1794,'Clients given 6E weighing 0-3.9 kg','Clients given 6E weighing 0-3.9 kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 0-3.9 kg\n Clients given 6E weighing 0-3.9 kg\n \n 2022-07-05 06:27:58 UTC\n \n 2022-07-05 06:30: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 1794\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:57:58',4,'2022-07-05 12:00:43',4,0,NULL,NULL,NULL,'ddcdfef8-c5fd-4bd2-9963-4d5d48702f57'),(1795,'Clients given 6E weighing 4-5.9 kg','Clients given 6E weighing 4-5.9 kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 4-5.9 kg\n Clients given 6E weighing 4-5.9 kg\n \n 2022-07-05 06:28:17 UTC\n \n 2022-07-05 06:32: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 1795\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 11:58:17',4,'2022-07-05 12:02:01',4,0,NULL,NULL,NULL,'52757686-f3a7-4d53-84bb-76aea347f4d3'),(1796,'Clients given 6E weighing 6-9.9 kg','Clients given 6E weighing 6-9.9 kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 6-9.9 kg\n Clients given 6E weighing 6-9.9 kg\n \n 2022-07-05 06:30:03 UTC\n \n 2022-07-05 06: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 1796\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','2022-07-05 12:00:03',4,'2022-07-05 12:01:15',4,0,NULL,NULL,NULL,'d0682189-7d23-4c17-9648-ae39ea0f6916'); +INSERT INTO `serialized_object` VALUES (1797,'Clients given 6E weighing 10-13.9 kg','Clients given 6E weighing 10-13.9 kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 10-13.9 kg\n Clients given 6E weighing 10-13.9 kg\n \n 2022-07-05 06:32:34 UTC\n \n 2022-07-05 06:34: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 1797\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:02:34',4,'2022-07-05 12:04:30',4,0,NULL,NULL,NULL,'ad8a6b3c-88dd-4328-b042-076242f1ce54'),(1798,'Clients given 6E weighing 14-19.9 kg','Clients given 6E weighing 14-19.9 kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 14-19.9 kg\n Clients given 6E weighing 14-19.9 kg\n \n 2022-07-05 06:33:01 UTC\n \n 2022-07-05 06: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 1798\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:03:01',4,'2022-07-05 12:04:51',4,0,NULL,NULL,NULL,'d58c1b55-d21c-497a-b201-c1f544c8264c'),(1799,'Clients given 6E weighing 20-24.9 kg','Clients given 6E weighing 20-24.9 kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 20-24.9 kg\n Clients given 6E weighing 20-24.9 kg\n \n 2022-07-05 06:33:24 UTC\n \n 2022-07-05 06:35: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 1799\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:03:24',4,'2022-07-05 12:05:10',4,0,NULL,NULL,NULL,'e38de12c-6c72-4188-a8b7-b6d912e7baf2'),(1800,'Clients given 6E weighing 25-34.9 kg','Clients given 6E weighing 25-34.9 kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing 25-34.9 kg\n Clients given 6E weighing 25-34.9 kg\n \n 2022-07-05 06:35:31 UTC\n \n 2022-07-05 06:37: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 1800\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:05:31',4,'2022-07-05 12:07:03',4,0,NULL,NULL,NULL,'24def27b-738c-424e-b397-689a9fc28dd0'),(1801,'Clients given 6E weighing >= 35 kg','Clients given 6E weighing >= 35 kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E weighing >= 35 kg\n Clients given 6E weighing >= 35 kg\n \n 2022-07-05 06:35:59 UTC\n \n 2022-07-05 06:37: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 1801\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:05:59',4,'2022-07-05 12:07:19',4,0,NULL,NULL,NULL,'bc732e0d-7aa7-412d-855c-76442487b9c9'),(1802,'Clients given 6F weighing 4-5.9kg','Clients given 6F weighing 4-5.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 4-5.9kg\n Clients given 6F weighing 4-5.9kg\n \n 2022-07-05 06:38:03 UTC\n \n 2022-07-05 06:42: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 1802\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:08:03',4,'2022-07-05 12:12:09',4,0,NULL,NULL,NULL,'31aaf13e-0c70-472d-9d6f-8d288c6545d7'),(1803,'Clients given 6F weighing 0-3.9kg','Clients given 6F weighing 0-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 0-3.9kg\n Clients given 6F weighing 0-3.9kg\n \n 2022-07-05 06:38:38 UTC\n \n 2022-07-05 06:43: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 1803\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:08:38',4,'2022-07-05 12:13:27',4,0,NULL,NULL,NULL,'ec58cc67-3866-4031-a385-d5f40bf5fa80'),(1804,'Clients given 6F weighing 6-9.9kg','Clients given 6F weighing 6-9.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 6-9.9kg\n Clients given 6F weighing 6-9.9kg\n \n 2022-07-05 06:40:34 UTC\n \n 2022-07-05 06:42: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 1804\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','2022-07-05 12:10:34',4,'2022-07-05 12:12:24',4,0,NULL,NULL,NULL,'ece7781b-8125-44f0-8189-6f4f66258b2c'),(1805,'Clients given 6F weighing 10-13.9kg','Clients given 6F weighing 10-13.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 10-13.9kg\n Clients given 6F weighing 10-13.9kg\n \n 2022-07-05 06:44:04 UTC\n \n 2022-07-05 06:47: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 1805\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:14:04',4,'2022-07-05 12:17:25',4,0,NULL,NULL,NULL,'6cd6003e-fd2a-4acd-acbf-8025ed274332'),(1806,'Clients given 6F weighing 14-19.9kg','Clients given 6F weighing 14-19.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 14-19.9kg\n Clients given 6F weighing 14-19.9kg\n \n 2022-07-05 06:44:30 UTC\n \n 2022-07-05 06:50: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 1806\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:14:30',4,'2022-07-05 12:20:01',4,0,NULL,NULL,NULL,'c465345e-8ab1-45d7-972a-d39b87dd1ade'),(1807,'Clients given 6F weighing 20-24.9kg','Clients given 6F weighing 20-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 20-24.9kg\n Clients given 6F weighing 20-24.9kg\n \n 2022-07-05 06:44:51 UTC\n \n 2022-07-05 06: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 1807\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:14:51',4,'2022-07-05 12:16:42',4,0,NULL,NULL,NULL,'383ecc01-a8e6-42b4-83f3-eb9c2e48386b'),(1808,'Clients given 6F weighing 25-34.9kg','Clients given 6F weighing 25-34.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing 25-34.9kg\n Clients given 6F weighing 25-34.9kg\n \n 2022-07-05 06:49:35 UTC\n \n 2022-07-05 06: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 1808\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:19:35',4,'2022-07-05 12:24:29',4,0,NULL,NULL,NULL,'bacab6c2-b1d6-4a10-9f0d-ffb24844bae5'),(1809,'Clients given 6F weighing >= 35kg','Clients given 6F weighing >= 35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F weighing >= 35kg\n Clients given 6F weighing >= 35kg\n \n 2022-07-05 06:53:17 UTC\n \n 2022-07-05 06: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 1809\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-07-05 12:23:17',4,'2022-07-05 12:26:41',4,0,NULL,NULL,NULL,'2614b81d-6441-4ee3-b4a7-a15f3ba36ace'),(1810,'Children ARV Regimen_2ndLine_2022','Children ARV Regimen_2ndLine','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_2022\n Children ARV Regimen_2ndLine\n \n 2022-07-06 07:16:05 UTC\n \n 2022-07-06 10:13: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 1810\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','2022-07-06 07:16:05',4,'2022-07-06 10:13:16',4,0,NULL,NULL,NULL,'dffce2c4-7adc-497e-8216-fa138d0201b1'),(1811,'Children ARV Regimen_2ndLine 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 Data Set\n \n 2022-07-06 07:16:44 UTC\n \n 2022-07-06 10:11: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 1811\n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 5A0to3.9\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_Age\n Children 0to14\n \n \n \n \n \n 5A10to13.9\n \n \n \n \n \n \n \n \n \n 5A14to19.9\n \n \n \n \n \n \n \n \n \n 5A20to24.9\n \n \n \n \n \n \n \n \n \n 5A25to34.9\n \n \n \n \n \n \n \n \n \n 5A35plus\n \n \n \n \n \n \n \n \n \n 5A4to5.9\n \n \n \n \n \n \n \n \n \n 5A6to9.9\n \n \n \n \n \n \n \n \n \n 5B0to3.9\n \n \n \n \n \n \n \n \n \n 5B10to13.9\n \n \n \n \n \n \n \n \n \n 5B14to19.9\n \n \n \n \n \n \n \n \n \n 5B20to24.9\n \n \n \n \n \n \n \n \n \n 5B25to34.9\n \n \n \n \n \n \n \n \n \n 5B35plus\n \n \n \n \n \n \n \n \n \n 5B4to5.9\n \n \n \n \n \n \n \n \n \n 5B6to9.9\n \n \n \n \n \n \n \n \n \n 5C0to3.9\n \n \n \n \n \n \n \n \n \n 5C10to13.9\n \n \n \n \n \n \n \n \n \n 5C14to19.9\n \n \n \n \n \n \n \n \n \n 5C20to24.9\n \n \n \n \n \n \n \n \n \n 5C25to34.9\n \n \n \n \n \n \n \n \n \n 5C35plus\n \n \n \n \n \n \n \n \n \n 5C4to5.9\n \n \n \n \n \n \n \n \n \n 5C6to9.9\n \n \n \n \n \n \n \n \n \n 5D0to3.9\n \n \n \n \n \n \n \n \n \n 5D10to13.9\n \n \n \n \n \n \n \n \n \n 5D14to19.9\n \n \n \n \n \n \n \n \n \n 5D20to24.9\n \n \n \n \n \n \n \n \n \n 5D25to34.9\n \n \n \n \n \n \n \n \n \n 5D35plus\n \n \n \n \n \n \n \n \n \n 5D4to5.9\n \n \n \n \n \n \n \n \n \n 5D6to9.9\n \n \n \n \n \n \n \n \n \n 5E0to3.9\n \n \n \n \n \n \n \n \n \n 5E10to13.9\n \n \n \n \n \n \n \n \n \n 5E14to19.9\n \n \n \n \n \n \n \n \n \n 5E20to24.9\n \n \n \n \n \n \n \n \n \n 5E25to34.9\n \n \n \n \n \n \n \n \n \n 5E35plus\n \n \n \n \n \n \n \n \n \n 5E4to5.9\n \n \n \n \n \n \n \n \n \n 5E6to9.9\n \n \n \n \n \n \n \n \n \n 5F0to3.9\n \n \n \n \n \n \n \n \n \n 5F10to13.9\n \n \n \n \n \n \n \n \n \n 5F14to19.9\n \n \n \n \n \n \n 5F20to24.9\n \n \n \n \n \n \n \n \n \n 5F25to34.9\n \n \n \n \n \n \n \n \n \n 5F35plus\n \n \n \n \n \n \n \n \n \n 5F4to5.9\n \n \n \n \n \n \n \n \n \n 5F6to9.9\n \n \n \n \n \n \n \n \n \n 5G0to3.9\n \n \n \n \n \n \n \n \n \n 5G10to13.9\n \n \n \n \n \n \n \n \n \n 5G14to19.9\n \n \n \n \n \n \n \n \n \n 5G20to24.9\n \n \n \n \n \n \n \n \n \n 5G25to34.9\n \n \n \n \n \n \n \n \n \n 5G35plus\n \n \n \n \n \n \n \n \n \n 5G4to5.9\n \n \n \n \n \n \n \n \n \n 5G6to9.9\n \n \n \n \n \n \n \n \n \n 5H0to3.9\n \n \n \n \n \n \n \n \n \n 5H10to13.9\n \n \n \n \n \n \n \n \n \n 5H14to19.9\n \n \n \n \n \n \n \n \n \n 5H20to24.9\n \n \n \n \n \n \n \n \n \n 5H25to34.9\n \n \n \n \n \n \n \n \n \n 5H35plus\n \n \n \n \n \n \n \n \n \n 5H4to5.9\n \n \n \n \n \n \n \n \n \n 5H6to9.9\n \n \n \n \n \n \n \n \n \n','2022-07-06 07:16:44',4,'2022-07-06 10:11:25',4,0,NULL,NULL,NULL,'437a2414-1894-4eb5-8c13-356a8e2aa747'),(1812,'Children ARV Regimen_3rdLine_2022','Children ARV Regimen_3rdLine','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_2022\n Children ARV Regimen_3rdLine\n \n 2022-07-06 10:16:11 UTC\n \n 2022-07-06 10:16: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 1812\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','2022-07-06 10:16:11',4,'2022-07-06 10:16:23',4,0,NULL,NULL,NULL,'b6b0cf68-1305-49a2-8f43-30f3f175958d'),(1813,'Children ARV Regimen_3rdLine_2022 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_2022 Data Set\n \n 2022-07-06 10:16:23 UTC\n \n 2022-07-06 14:44: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 1813\n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n 6A0to3.9\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_Age\n Children 0to14\n \n \n \n \n \n 6A10to13.9\n \n \n \n \n \n \n \n \n \n 6A14to19.9\n \n \n \n \n \n \n \n \n \n 6A20to24.9\n \n \n \n \n \n \n \n \n \n 6A25to34.9\n \n \n \n \n \n \n \n \n \n 6A35plus\n \n \n \n \n \n \n \n \n \n 6A4to5.9\n \n \n \n \n \n \n \n \n \n 6A6to9.9\n \n \n \n \n \n \n \n \n \n 6B0to3.9\n \n \n \n \n \n \n \n \n \n 6B10to13.9\n \n \n \n \n \n \n \n \n \n 6B14to19.9\n \n \n \n \n \n \n \n \n \n 6B20to24.9\n \n \n \n \n \n \n \n \n \n 6B25to34.9\n \n \n \n \n \n \n \n \n \n 6B35plus\n \n \n \n \n \n \n \n \n \n 6B4to5.9\n \n \n \n \n \n \n \n \n \n 6B6to9.9\n \n \n \n \n \n \n \n \n \n 6C0to3.9\n \n \n \n \n \n \n \n \n \n 6C10to13.9\n \n \n \n \n \n \n \n \n \n 6C14to19.9\n \n \n \n \n \n \n \n \n \n 6C20to24.9\n \n \n \n \n \n \n \n \n \n 6C25to34.9\n \n \n \n \n \n \n \n \n \n 6C35plus\n \n \n \n \n \n \n \n \n \n 6C4to5.9\n \n \n \n \n \n \n \n \n \n 6C6to9.9\n \n \n \n \n \n \n \n \n \n 6D0to3.9\n \n \n \n \n \n \n \n \n \n 6D10to13.9\n \n \n \n \n \n \n \n \n \n 6D14to19.9\n \n \n \n \n \n \n \n \n \n 6D20to24.9\n \n \n \n \n \n \n \n \n \n 6D25to34.9\n \n \n \n \n \n \n \n \n \n 6D35plus\n \n \n \n \n \n \n \n \n \n 6D4to5.9\n \n \n \n \n \n \n \n \n \n 6D6to9.9\n \n \n \n \n \n \n \n \n \n 6E0to3.9\n \n \n \n \n \n \n \n \n \n 6E10to13.9\n \n \n \n \n \n \n \n \n \n 6E14to19.9\n \n \n \n \n \n \n \n \n \n 6E20to24.9\n \n \n \n \n \n \n \n \n \n 6E25to34.9\n \n \n \n \n \n \n \n \n \n 6E35plus\n \n \n \n \n \n \n \n \n \n 6E4to5.9\n \n \n \n \n \n \n \n \n \n 6E6to9.9\n \n \n \n \n \n \n \n \n \n 6F0to3.9\n \n \n \n \n \n \n \n \n \n 6F10to13.9\n \n \n \n \n \n \n \n \n \n 6F14to19.9\n \n \n \n \n \n \n \n \n \n 6F20to24.9\n \n \n \n \n \n \n \n \n \n 6F25to34.9\n \n \n \n \n \n \n \n \n \n 6F35plus\n \n \n \n \n \n \n \n \n \n 6F4to5.9\n \n \n \n \n \n \n \n \n \n 6F6to9.9\n \n \n \n \n \n \n \n \n \n','2022-07-06 10:16:23',4,'2022-07-06 14:44:30',4,0,NULL,NULL,NULL,'3fa2b422-d556-4710-bfd7-bc8a5b0c9c0b'),(1814,'TX_ML-06 Clients who are current on ART at reporting period and experienced IIT_3-5 months','TX_ML-06 Clients who are current on ART at reporting period and experienced IIT_3-5 months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_ML-06 Clients who are current on ART at reporting period and experienced IIT_3-5 months\n TX_ML-06 Clients who are current on ART at reporting period and experienced IIT_3-5 months\n \n 2022-08-10 11:03:51 UTC\n \n 2024-02-15 09:03: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 1814\n select obs_ml_clients.person_id \nfrom obs os \ninner join location l on os.location_id = l.location_id \ninner join \n( \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) < 29) as On_ART_Beginning_Quarter \n ) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n UNION \n select o.person_id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND patient.voided = 0 AND o.voided = 0 \n AND o.concept_id = 2249 and cast(o.value_datetime as date) >= cast(:startDate as DATE) and cast(o.value_datetime as date) <= cast(:endDate as DATE) \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) > 28) as Missed_Greater_Than_28Days \n ) \n INNER JOIN patient_identifier ON patient_identifier.patient_id = patient.patient_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n group by patient.patient_id \n) as obs_ml_clients on os.person_id = obs_ml_clients.person_id \nINNER JOIN person ON person.person_id = obs_ml_clients.person_id AND person.voided = 0 \nINNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \nWHERE os.location_id =:location or parent_location =:location \n -- INITIATED ON ART BETWEEN 3 AND 5 MONTHS AGO \n AND obs_ml_clients.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 2249 \n AND datediff(CAST(:endDate AS DATE), os.value_datetime) BETWEEN 89 AND 180 \n ) \n -- NOT Transfered Out to Another Site \n AND obs_ml_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 4155 and os.value_coded = 2146 \n AND os.obs_datetime <= CAST(:endDate AS DATE) \n ) \n -- NOT DEAD \n AND obs_ml_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 ) \nAND obs_ml_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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n )\n','2022-08-10 16:33:51',4,'2024-02-15 14:33:32',4,0,NULL,NULL,NULL,'e2a2e29e-040a-45b1-902d-fa25074d52a1'),(1815,'CI63:TxML IIT3-5','TxML IIT3-5','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI63:TxML IIT3-5\n TxML IIT3-5\n \n 2022-08-10 11:07:17 UTC\n \n 2022-08-10 11:08: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 1815\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-08-10 11:07:17',4,'2022-08-10 11:08:59',4,0,NULL,NULL,NULL,'781f34cd-9cce-41ef-acbe-b89b0e1257e4'),(1816,'TX_RTT-02 Clients with IIT for < 3 months in previous period who restarted ARV\'s during current period','TX_RTT-02 Clients with IIT for < 3 months in previous period who restarted ARV\'s during current period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_RTT-02 Clients with IIT for < 3 months in previous period who restarted ARV's during current period\n TX_RTT-02 Clients with IIT for < 3 months in previous period who restarted ARV's during current period\n \n 2022-08-23 16:34:31 UTC\n \n 2024-02-15 08:22: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 1816\n select distinct o.person_id \nfrom obs o \n-- PATIENTS WITH NO CLINICAL CONTACT OR ARV PICK-UP FOR GREATER THAN 28 DAYS \n-- SINCE THEIR LAST EXPECTED CONTACT WHO RESTARTED ARVs WITHIN THE REPORTING PERIOD \ninner join location l on o.location_id = l.location_id \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND patient.voided = 0 AND o.voided = 0 \nAND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) BETWEEN 29 and 90) as Missed_Greater_Than_28Days \n ) \n \n -- Client Seen: As either patient OR Treatment Buddy \n AND ( \n o.person_id 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 os.obs_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n \n -- Client Seen and Date Restarted picked \n OR o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 3708 AND os.value_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n ) \n -- Still on treatment at the end of the reporting period \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime >= cast(:startDate as DATE) and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) <= 28) as Still_On_Treatment_End_Period \n ) \n \n -- Transfered Out to Another Site during their latest encounter before the start date \n AND o.person_id not in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS last_obs_tout \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 4155 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having last_obs_tout = 2146) as Transfered_Out_In_Last_Encounter \n ) \n \n-- NOT Transfered In from another Site \n AND o.person_id not in ( \n select os.person_id \n from obs os \n where (os.concept_id = 2253 AND DATE(os.value_datetime) BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE)) \n AND os.voided = 0 \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 \n ) \n AND o.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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \nWHERE (o.location_id =:location or parent_location =:location)\n','2022-08-23 22:04:31',4,'2024-02-15 13:52:47',4,0,NULL,NULL,NULL,'505841df-fa38-436c-8463-8a437f536b69'),(1817,'TX_RTT-03 Clients with IIT for 3-5 months in previous period who restarted ARV\'s during current period','TX_RTT-03 Clients with IIT for 3-5 months in previous period who restarted ARV\'s during current period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_RTT-03 Clients with IIT for 3-5 months in previous period who restarted ARV's during current period\n TX_RTT-03 Clients with IIT for 3-5 months in previous period who restarted ARV's during current period\n \n 2022-08-23 16:42:57 UTC\n \n 2024-02-15 08:26: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 1817\n select distinct o.person_id \nfrom obs o \n-- PATIENTS WITH NO CLINICAL CONTACT OR ARV PICK-UP FOR GREATER THAN 28 DAYS \n-- SINCE THEIR LAST EXPECTED CONTACT WHO RESTARTED ARVs WITHIN THE REPORTING PERIOD \ninner join location l on o.location_id = l.location_id \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND patient.voided = 0 AND o.voided = 0 \nAND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) BETWEEN 89 and 180) as Missed_Between_89_and_180Days \n ) \n \n -- Client Seen: As either patient OR Treatment Buddy \n AND ( \n o.person_id 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 os.obs_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n \n -- Client Seen and Date Restarted picked \n OR o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 3708 AND os.value_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n ) \n -- Still on treatment at the end of the reporting period \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime >= cast(:startDate as DATE) and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) <= 28) as Still_On_Treatment_End_Period \n ) \n \n -- Transfered Out to Another Site during their latest encounter before the start date \n AND o.person_id not in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS last_obs_tout \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 4155 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having last_obs_tout = 2146) as Transfered_Out_In_Last_Encounter \n ) \n \n-- NOT Transfered In from another Site \n AND o.person_id not in ( \n select os.person_id \n from obs os \n where (os.concept_id = 2253 AND DATE(os.value_datetime) BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE)) \n AND os.voided = 0 \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 \n ) \n AND o.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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \nWHERE (o.location_id =:location or parent_location =:location)\n','2022-08-23 22:12:57',4,'2024-02-15 13:56:51',4,0,NULL,NULL,NULL,'129f5049-8d6d-4cd9-8922-7cf72b623ab3'),(1818,' TX_RTT-04 Clients with IIT for >6 months in previous period who restarted ARV\'s during current period',' TX_RTT-04 Clients with IIT for >6 months in previous period who restarted ARV\'s during current period','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TX_RTT-04 Clients with IIT for >6 months in previous period who restarted ARV's during current period\n TX_RTT-04 Clients with IIT for >6 months in previous period who restarted ARV's during current period\n \n 2022-08-23 16:45:46 UTC\n \n 2024-02-15 08:42: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 endDateAS\n \n java.util.Date\n true\n \n \n 1818\n select distinct o.person_id \nfrom obs o \n-- PATIENTS WITH NO CLINICAL CONTACT OR ARV PICK-UP FOR GREATER THAN 28 DAYS \n-- SINCE THEIR LAST EXPECTED CONTACT WHO RESTARTED ARVs WITHIN THE REPORTING PERIOD \ninner join location l on o.location_id = l.location_id \nINNER JOIN patient ON o.person_id = patient.patient_id \nAND patient.voided = 0 AND o.voided = 0 \nAND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having datediff(CAST(DATE_ADD(CAST(:startDate AS DATE), INTERVAL -1 DAY) AS DATE), latest_follow_up) >= 180) as Missed_Greater_than_180Days \n ) \n \n -- Client Seen: As either patient OR Treatment Buddy \n AND ( \n o.person_id 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 os.obs_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n \n -- Client Seen and Date Restarted picked \n OR o.person_id in ( \n select distinct os.person_id \n from obs os \n where os.concept_id = 3708 AND os.value_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE) \n ) \n ) \n -- Still on treatment at the end of the reporting period \n AND o.person_id in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_datetime)), 20) AS latest_follow_up \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 3752 and oss.voided=0 \n and oss.obs_datetime >= cast(:startDate as DATE) and oss.obs_datetime <= cast(:endDate as DATE) \n group by p.person_id \n having datediff(CAST(:endDate AS DATE), latest_follow_up) <= 28) as Still_On_Treatment_End_Period \n ) \n \n -- Transfered Out to Another Site during their latest encounter before the start date \n AND o.person_id not in ( \n select person_id \n from \n (select oss.person_id, MAX(oss.obs_datetime) as max_observation, SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) AS last_obs_tout \n from obs oss \n inner join person p on oss.person_id=p.person_id and oss.concept_id = 4155 and oss.voided=0 \n and oss.obs_datetime < cast(:startDate as DATE) \n group by p.person_id \n having last_obs_tout = 2146) as Transfered_Out_In_Last_Encounter \n ) \n \n-- NOT Transfered In from another Site \n AND o.person_id not in ( \n select os.person_id \n from obs os \n where (os.concept_id = 2253 AND DATE(os.value_datetime) BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE)) \n AND os.voided = 0 \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 \n ) \n AND o.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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \nWHERE (o.location_id =:location or parent_location =:location)\n','2022-08-23 22:15:46',4,'2024-02-15 14:12:31',4,0,NULL,NULL,NULL,'afc2a5d5-53e4-427a-9491-b3b1609bbe69'),(1819,'CI64:TxRTT IIT<3months','CI64:TxRTT IIT<3months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI64:TxRTT IIT<3months\n CI64:TxRTT IIT<3months\n \n 2022-08-24 07:46:14 UTC\n \n 2022-08-24 07:47: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 1819\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-08-24 07:46:14',4,'2022-08-24 07:47:14',4,0,NULL,NULL,NULL,'6c4e2daf-e83f-4899-98f5-203f33ee4827'),(1820,'CI65:TxRTT IIT_3-5months','CI65:TxRTT IIT_3-5months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI65:TxRTT IIT_3-5months\n CI65:TxRTT IIT_3-5months\n \n 2022-08-24 07:47:56 UTC\n \n 2022-08-24 07:48: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 1820\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-08-24 07:47:56',4,'2022-08-24 07:48:48',4,0,NULL,NULL,NULL,'714af509-9ade-48b5-b6f0-10d7499a6f15'),(1821,'CI66:TxRTT IIT_6+months','CI66:TxRTT IIT_6+months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n CI66:TxRTT IIT_6+months\n CI66:TxRTT IIT_6+months\n \n 2022-08-24 07:49:18 UTC\n \n 2022-08-24 07:49: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 1821\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2022-08-24 07:49:18',4,'2022-08-24 07:49:56',4,0,NULL,NULL,NULL,'271261f4-75c6-4c64-a6f0-7be2d40c33c3'),(1822,'Pulmonary Bacteriologically Confirmed New','New Pulmonary Bacteriologically Confirmed clients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Bacteriologically Confirmed New\n New Pulmonary Bacteriologically Confirmed clients\n \n 2023-03-27 10:50:04 UTC\n \n 2023-03-29 16:41: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 1822\n select distinct o.person_id \n \n from obs o \ninner join location l on o.location_id = l.location_id \n \n -- Relapsed TB Client \nWHERE (o.location_id =:location or parent_location =:location) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n -- TB Start Date \n where ob.concept_id = 2237 \n and ob.value_datetime >= :startDate \n and ob.value_datetime <= :endDate \n and ob.voided = 0 \n ) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- New Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1034 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n ) \n \n \n AND o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Patient must not be a tranfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND (os.obs_datetime BETWEEN :startDate AND :endDate) \n AND os.voided = 0 \n )\n','2023-03-27 12:50:04',4,'2023-03-29 18:41:33',4,0,NULL,NULL,NULL,'5ab3fc4d-0d1e-4a30-b0c7-d35c68f7f19a'),(1823,'NewRelapse_Tb_Treatment_History','Tb Treatment History - New and Relapse Patients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n NewRelapse_Tb_Treatment_History\n Tb Treatment History - New and Relapse Patients\n \n 2023-03-27 11:51:48 UTC\n \n 2023-03-27 20:29: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 1823\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age , Gender, age_group, 'New Patient' AS 'TB_Treatment_History' \n FROM \n \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 -- New TB Patient \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n -- TB Start Date \n where ob.concept_id = 2237 \n and ob.value_datetime >= CAST(:startDate AS DATE) \n and ob.value_datetime <= CAST(:endDate AS DATE) \n and ob.voided = 0 \n ) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- New Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1034 \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \n \n AND o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Patient must not be a tranfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND (os.obs_datetime BETWEEN CAST(:startDate AS DATE) AND CAST(:endDate AS DATE)) \n AND patient.voided = 0 AND os.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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n \n UNION \n \n (SELECT distinct Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name", Age , Gender, age_group, 'Relapsed Patient' AS 'TB_Treatment_History' \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 -- Relapsed TB Client \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n -- TB Start Date \n where ob.concept_id = 2237 \n and ob.value_datetime >= CAST(:startDate AS DATE) \n and ob.value_datetime <= CAST(:endDate AS DATE) \n ) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- Relapsed Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1084 \n and ob.value_datetime >= CAST(:startDate AS DATE) \n and ob.value_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \n \n \n AND o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Client must not be a transfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND os.obs_datetime >= CAST(:startDate AS DATE) \n and os.obs_datetime <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND os.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 \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 RELAPSE_TB_CLIENTS \n ORDER BY RELAPSE_TB_CLIENTS.Age) \n) AS NewRelapsed)\n','2023-03-27 17:21:48',4,'2023-03-28 01:59:53',4,0,NULL,NULL,NULL,'7f8a23bd-eec0-40a6-8181-cda3d0aab0bd'),(1824,'Pulmonary Bacteriologically Confirmed Relapse','Pulmonary Bacteriologically Confirmed Relapse','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Bacteriologically Confirmed Relapse\n Pulmonary Bacteriologically Confirmed Relapse\n \n 2023-03-27 12:10:01 UTC\n \n 2023-03-29 16:45: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 1824\n select o.person_id \n from obs o \ninner join location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \nWHERE (o.location_id =:location or parent_location =:location) \nAND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n -- TB Start Date \n where ob.concept_id = 2237 \n and ob.value_datetime >= :startDate \n and ob.value_datetime <= :endDate \n ) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- Relapsed Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1084 \n and ob.value_datetime >= :startDate \n and ob.value_datetime <= :endDate \n ) \n ) \n \n \n \n AND o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Client must not be a transfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND os.obs_datetime >= :startDate \n and os.obs_datetime <= :endDate \n AND patient.voided = 0 AND os.voided = 0 \n )\n','2023-03-27 14:10:01',4,'2023-03-29 18:45:37',4,0,NULL,NULL,NULL,'e495a330-c538-4fa2-9279-e0c03ec69b51'),(1825,'Pulmonary Bacteriologically Confirmed Excluding Relapse','Pulmonary Bacteriologically Confirmed Excluding Relapse','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Bacteriologically Confirmed Excluding Relapse\n Pulmonary Bacteriologically Confirmed Excluding Relapse\n \n 2023-03-27 17:01:52 UTC\n \n 2023-03-29 16:38: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 1825\n select distinct o.person_id \n from obs o \ninner join location l on o.location_id = l.location_id \n \n -- Relapsed TB Client \nWHERE (o.location_id =:location or parent_location =:location) \n AND o.concept_id = 3785 and o.value_coded in (3786,1037) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n -- TB Start Date \n where ob.concept_id = 2237 \n and ob.value_datetime >= :startDate \n and ob.value_datetime <= :endDate \n ) \n \n AND o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Client must not be a transfer in \n where os.concept_id = 3772 and os.value_coded = 3786 \n AND os.obs_datetime >= :startDate \n and os.obs_datetime <= :endDate \n AND os.voided = 0) \n\n','2023-03-27 19:01:52',4,'2023-03-29 18:38:41',4,0,NULL,NULL,NULL,'23ba6606-91b7-4f7c-9142-73d6a43769a3'),(1826,'New and Relapse with document HIV Status','New and Relapse patients with document HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse with document HIV Status\n New and Relapse patients with document HIV Status\n \n 2023-03-27 19:38:11 UTC\n \n 2023-03-27 21:21: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 1826\n SELECT DISTINCT o.person_id \n from obs o \n -- New and Relapse with Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3785 and ob.value_coded in (1034, 1084) -- New and Relapse \n and ob.voided = 0 \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE)\n','2023-03-28 01:08:11',4,'2023-03-28 02:51:39',4,0,NULL,NULL,NULL,'ee4e2170-5dd7-423e-bc84-f0c13c3a9b4f'),(1827,'Retreatment with documented HIV status','Retreatment Excl. Relapse client with documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment with documented HIV status\n Retreatment Excl. Relapse client with documented HIV Status\n \n 2023-03-27 19:50:19 UTC\n \n 2023-03-27 19:53: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 1827\n SELECT DISTINCT o.person_id \n from obs o \n -- New and Relapse with Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3785 and ob.value_coded in (3786, 1037) -- Retreatmentafter LTFU/Failure \n and ob.voided = 0 \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 01:20:19',4,'2023-03-28 01:23:28',4,0,NULL,NULL,NULL,'17edcc8f-3d38-49dd-a6f4-a5384cdb7245'),(1828,'Children < 15 with Documented HIV Status','Children (0 - 14) with documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children < 15 with Documented HIV Status\n Children (0 - 14) with documented HIV Status\n \n 2023-03-27 20:10:47 UTC\n \n 2023-03-27 20:11:20 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 1828\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 \n from obs o \n -- Documented HIV, Status \n inner join location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \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 having Age < 15\n','2023-03-28 01:40:47',4,'2023-03-28 01:41:20',4,0,NULL,NULL,NULL,'ca5b1d37-8229-474d-8125-2486520685fd'),(1829,'Pulmonary Clinically Diagnosed New','Pulmonary Clinically Diagnosed New','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Clinically Diagnosed New\n Pulmonary Clinically Diagnosed New\n \n 2023-03-27 20:39:34 UTC\n \n 2024-05-20 17:07: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 1829\n select distinct Id \n FROM \n -- Clinical Diagnosis X-Ray \n ( \n \n Select distinct person_id as Id, max_observation, examination_timing,o.voided \n from obs o \n inner join \n ( \n select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.obs_id)), 20) as examination_timing \n from obs oss \n where oss.concept_id = 4153 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n and oss.voided = 0 \n group by oss.person_id \n \n )latest \n on latest.Id = o.person_id \n where o.concept_id = 4673 and o.value_coded = 4171 \n and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n and o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Patient must not be a tranfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND (os.obs_datetime BETWEEN :startDate AND :endDate) \n and os.voided = 0 \n ) \n group by Id \n )as XRay_Clients \n \n -- Site (Pulmonary) \n inner join ( \n select distinct ob.person_id as pId \n FROM obs ob \n -- Pulmonary TB \n where ob.concept_id = 3788 and ob.value_coded = 1018 \n AND cast(ob.obs_datetime as date) >= CAST(:startDate AS DATE) \n and cast(ob.obs_datetime as date) <= CAST(:endDate AS DATE) \n and ob.voided = 0 \n group by pId \n ) As Pulmonary \n on XRay_Clients.Id = Pulmonary.pId \n \n inner join ( \n select distinct person_id as pId \n from obs ob \n where concept_id = 3785 and value_coded = 1034 \n and cast(ob.obs_datetime as date) >= :startDate \n and cast(ob.obs_datetime as date) <= :endDate \n \n ) As New_Client \n on XRay_Clients.Id = New_Client.pId\n','2023-03-28 02:09:34',4,'2024-05-20 22:37:14',4,0,NULL,NULL,NULL,'34bcf70d-0178-4dcc-ab38-9046e4bcedd1'),(1830,'Miners with Documented HIV Status','High risk population of miners with documented HIV','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Miners with Documented HIV Status\n High risk population of miners with documented HIV\n \n 2023-03-27 20:45:17 UTC\n \n 2023-03-27 20: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 1830\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3667 -- Population (Miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 02:15:17',4,'2023-03-28 02:16:08',4,0,NULL,NULL,NULL,'001d7c51-fa6b-45d5-9690-cc6dce14a608'),(1831,'Ex-Miners with Documented HIV Status','High risk population of Ex Miners with Documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex-Miners with Documented HIV Status\n High risk population of Ex Miners with Documented HIV Status\n \n 2023-03-27 20:47:57 UTC\n \n 2023-03-28 09:17: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 1831\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3668 -- Population (Ex-Miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 02:17:57',4,'2023-03-28 14:47:41',4,0,NULL,NULL,NULL,'10248e4b-2f29-447e-814a-6d5b10398656'),(1832,'Factory Workers with Documented HIV Status','High risk population of Factory Workers with Documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Workers with Documented HIV Status\n High risk population of Factory Workers with Documented HIV Status\n \n 2023-03-27 20:54:48 UTC\n \n 2023-03-27 20:55: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 1832\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3669 -- Population (Factory Workers) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 02:24:48',4,'2023-03-28 02:25:05',4,0,NULL,NULL,NULL,'bb934645-58c2-4c19-bbd7-0ebf35fa3f7a'),(1833,'Public transport operators with Documented HIV Status','High risk population of Public transport operators with Documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public transport operators with Documented HIV Status\n High risk population of Public transport operators with Documented HIV Status\n \n 2023-03-27 20:58:19 UTC\n \n 2023-03-28 20:14: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 1833\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 4654 -- Population (Public transport operators) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 02:28:19',4,'2023-03-29 01:44:32',4,0,NULL,NULL,NULL,'0c91b258-01ae-4928-be76-91201cadad93'),(1834,'Health workers with Documented HIV Status','High risk population of Health workers with Documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health workers with Documented HIV Status\n High risk population of Health workers with Documented HIV Status\n \n 2023-03-27 21:04:15 UTC\n \n 2023-03-27 21:04: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 1834\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 4670 -- Population (Health workers) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 02:34:15',4,'2023-03-28 02:34:38',4,0,NULL,NULL,NULL,'7736630e-9da2-4ec0-b131-fe9e2ef01e00'),(1835,'Correctional Staff and inmates with Documented HIV Status','High risk population of Correctional Staff and inmates with Documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Correctional Staff and inmates with Documented HIV Status\n High risk population of Correctional Staff and inmates with Documented HIV Status\n \n 2023-03-27 21:06:32 UTC\n \n 2023-03-27 21:10: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 1835\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded in (3779, 3671) -- Population (Correctional Staff and inmates) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 02:36:32',4,'2023-03-28 02:40:03',4,0,NULL,NULL,NULL,'58ac8a09-0a12-4ab0-acb4-1fe8d1d81b77'),(1836,'RetreatmentExRelapse_Tb_Treatment_History','Retreatment Exclusive Relapse Tb Treatment History','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n RetreatmentExRelapse_Tb_Treatment_History\n Retreatment Exclusive Relapse Tb Treatment History\n \n 2023-03-27 21:07:51 UTC\n \n 2023-03-27 21:12: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 1836\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 Id \nFROM \n((SELECT distinct Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- TB Retreatment Exclusive Relapse \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- TB Retreatment Exclusive Relapse \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded in (3786,1037) \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) AS RetreatmentExRelapse)\n','2023-03-28 02:37:51',4,'2023-03-28 02:42:07',4,0,NULL,NULL,NULL,'7263505b-34d2-4167-9d3f-4cdae66218f8'),(1837,'NewRelapse_Tb_Treatment_History','NewRelapse_Tb_Treatment_History','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n NewRelapse_Tb_Treatment_History\n NewRelapse_Tb_Treatment_History\n \n 2023-03-27 21:17:20 UTC\n \n 2023-03-27 21: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 1837\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-28 02:47:20',4,'2023-03-28 02:50:31',4,0,NULL,NULL,NULL,'20879b46-ecbd-4ff9-818a-3c761bcf5ebd'),(1838,'New and Relapse with Positive HIV Status','New and Relapse with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse with Positive HIV Status\n New and Relapse with Positive HIV Status\n \n 2023-03-27 21:20:17 UTC\n \n 2023-03-29 20:36: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 1838\n SELECT DISTINCT o.person_id \n from obs o \n -- New and Relapse with Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3785 and ob.value_coded in (1034, 1084) -- New/Relapse with HIV Status \n and ob.voided = 0 \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-27 23:20:17',4,'2023-03-29 22:36:19',4,0,NULL,NULL,NULL,'02c505a1-b724-422b-8c31-69440e233a0d'),(1839,'RetreatmentExRelapse_Tb_Treatment_History','Retreatment Exclusive Relapse - Tb Treatment History','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n RetreatmentExRelapse_Tb_Treatment_History\n Retreatment Exclusive Relapse - Tb Treatment History\n \n 2023-03-27 21:25:15 UTC\n \n 2023-03-27 21:26: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 1839\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-28 02:55:15',4,'2023-03-28 02:56:10',4,0,NULL,NULL,NULL,'f901b38b-95e7-4bcc-ace1-ce86030ba88e'),(1840,'TB Notification - Block 2','TB Notification - Block 2','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Notification - Block 2\n TB Notification - Block 2\n \n 2023-03-27 21:45:01 UTC\n \n 2023-03-27 21:45: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 1840\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-03-28 03:15:01',4,'2023-03-28 03:15:21',4,0,NULL,NULL,NULL,'8ab1160e-aca4-4d59-bd02-0269e8a3889a'),(1841,'TB Notification - 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 Notification - Block 2 Data Set\n \n 2023-03-27 21:45:21 UTC\n \n 2024-02-29 14:25: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 1841\n \n \n DM_Sex\n \n \n \n \n \n \n DM_TB_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n NwRlpsF1-4\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_TB_Age\n 01-04yrs\n \n \n \n \n \n NwRlpsF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 05-09yrs\n \n \n \n \n \n NwRlpsM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 01-04yrs\n \n \n \n \n \n NwRlpsM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 05-09yrs\n \n \n \n \n \n NwRlpseF<1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n Under1yr\n \n \n \n \n \n NwRlpseM<1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n Under1yr\n \n \n \n \n \n NwRsF10-14\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 10-14yrs\n \n \n \n \n \n NwRsF15-19\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 15-19yrs\n \n \n \n \n \n NwRsF20-24\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 20-24yrs\n \n \n \n \n \n NwRsF25-34\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 25-34yrs\n \n \n \n \n \n NwRsF35-44\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 35-44yrs\n \n \n \n \n \n NwRsF45-49\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 45-49yrs\n \n \n \n \n \n NwRsF50-64\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 50-64yrs\n \n \n \n \n \n NwRsF65+\n \n \n \n \n DM_Sex\n Females\n \n \n DM_TB_Age\n 65Plus\n \n \n \n \n \n NwRsM10-14\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 10-14yrs\n \n \n \n \n \n NwRsM15-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 15-19yrs\n \n \n \n \n \n NwRsM20-24\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 20-24yrs\n \n \n \n \n \n NwRsM25-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 25-34yrs\n \n \n \n \n \n NwRsM35-44\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 35-44yrs\n \n \n \n \n \n NwRsM45-49\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 45-49yrs\n \n \n \n \n \n NwRsM50-64\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 50-64yrs\n \n \n \n \n \n NwRsM65+\n \n \n \n \n DM_Sex\n Males\n \n \n DM_TB_Age\n 65Plus\n \n \n \n \n \n RetreatF<1\n \n \n \n \n \n \n \n \n \n RetreatM<1\n \n \n \n \n \n \n RetrtF1-4\n \n \n \n \n \n \n RetrtF5-9\n \n \n \n \n \n \n RetrtM1-4\n \n \n \n \n \n \n RetrtM5-9\n \n \n \n \n \n \n RtrtF10-14\n \n \n \n \n \n \n RtrtF15-19\n \n \n \n \n \n \n RtrtF20-24\n \n \n \n \n \n \n RtrtF25-34\n \n \n \n \n \n \n RtrtF35-44\n \n \n \n \n \n \n RtrtF45-49\n \n \n \n \n \n \n RtrtF50-64\n \n \n \n \n \n \n RtrtF65+\n \n \n \n \n \n \n RtrtM10-14\n \n \n \n \n \n \n RtrtM15-19\n \n \n \n \n \n \n RtrtM20-24\n \n \n \n \n \n \n RtrtM25-34\n \n \n \n \n \n \n RtrtM35-44\n \n \n \n \n \n \n RtrtM45-49\n \n \n \n \n \n \n RtrtM50-64\n \n \n \n \n \n \n RtrtM65+\n \n \n \n \n \n \n','2023-03-28 03:15:21',4,'2024-02-29 19:55:50',4,0,NULL,NULL,NULL,'68f0aaca-a6a0-4cb5-aebb-e57d5ce5b2cd'),(1844,'Retreatment with Positive HIV status','Retreatment Excl. Relapse with Positive HIV status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment with Positive HIV status\n Retreatment Excl. Relapse with Positive HIV status\n \n 2023-03-28 08:28:56 UTC\n \n 2023-03-28 08:30: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 1844\n SELECT DISTINCT o.person_id \n from obs o \n -- New and Relapse with Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3785 and ob.value_coded in (3786, 1037) -- Retreatmentafter LTFU/Failure with HIV Status \n and ob.voided = 0 \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 13:58:56',4,'2023-03-28 14:00:38',4,0,NULL,NULL,NULL,'d48e3545-1e4d-4d7a-a812-5fb7111cbf72'),(1845,'Pulmonary Clinically Diagnosed Relapse','Pulmonary Clinically Diagnosed Relapse','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Clinically Diagnosed Relapse\n Pulmonary Clinically Diagnosed Relapse\n \n 2023-03-28 08:30:26 UTC\n \n 2024-05-20 17:08: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 1845\n \n select distinct Id \n FROM \n -- Clinical Diagnosis X-Ray \n ( \n \n Select distinct person_id as Id, max_observation, examination_timing,o.voided \n from obs o \n inner join \n ( \n select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.obs_id)), 20) as examination_timing \n from obs oss \n where oss.concept_id = 4153 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n and oss.voided = 0 \n group by oss.person_id \n \n )latest \n on latest.Id = o.person_id \n where o.concept_id = 4673 and o.value_coded = 4171 \n and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n and o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Patient must not be a tranfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND (os.obs_datetime BETWEEN :startDate AND :endDate) \n and os.voided = 0 \n ) \n group by Id \n )as XRay_Clients \n \n -- Site (Pulmonary) \n inner join ( \n select distinct ob.person_id as pId \n FROM obs ob \n -- Pulmonary TB \n where ob.concept_id = 3788 and ob.value_coded = 1018 \n AND cast(ob.obs_datetime as date) >= CAST(:startDate AS DATE) \n and cast(ob.obs_datetime as date) <= CAST(:endDate AS DATE) \n and ob.voided = 0 \n group by pId \n ) As Pulmonary \n on XRay_Clients.Id = Pulmonary.pId \n \n inner join ( \n select distinct person_id as pId \n from obs ob \n where concept_id = 3785 and value_coded = 1084 \n and cast(ob.obs_datetime as date) >= :startDate \n and cast(ob.obs_datetime as date) <= :endDate \n \n ) As New_Client \n on XRay_Clients.Id = New_Client.pId\n','2023-03-28 14:00:26',4,'2024-05-20 22:38:37',4,0,NULL,NULL,NULL,'5d45f128-1037-42d6-939d-3ae6929bfd6c'),(1846,'DM_TB_Age','DM_TB_Age','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n DM_TB_Age\n DM_TB_Age\n \n 2023-03-28 08:34:09 UTC\n \n 2024-02-29 14:04:18 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n 1846\n \n \n 01-04yrs\n \n \n \n \n maxAge\n 4\n \n \n minAge\n 1\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 05-09yrs\n \n \n \n \n maxAge\n 9\n \n \n minAge\n 5\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 10-14yrs\n \n \n \n \n maxAge\n 14\n \n \n minAge\n 10\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 15-19yrs\n \n \n \n \n maxAge\n 19\n \n \n minAge\n 15\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 20-24yrs\n \n \n \n \n maxAge\n 24\n \n \n minAge\n 20\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 25-34yrs\n \n \n \n \n maxAge\n 34\n \n \n minAge\n 25\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 35-44yrs\n \n \n \n \n maxAge\n 44\n \n \n minAge\n 35\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 45-49yrs\n \n \n \n \n maxAge\n 49\n \n \n minAge\n 45\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 50-64yrs\n \n \n \n \n maxAge\n 64\n \n \n minAge\n 50\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 65Plus\n \n \n \n \n maxAge\n 120\n \n \n minAge\n 65\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n Under1yr\n \n \n \n \n maxAge\n 0\n \n \n minAge\n 0\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n','2023-03-28 14:04:09',4,'2024-02-29 19:34:18',4,0,NULL,NULL,NULL,'68d03856-4b9b-4d8d-ba8f-bc698222c9f2'),(1847,'Children < 15 with Positive HIV Status','High risk population for Children < 15 with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children < 15 with Positive HIV Status\n High risk population for Children < 15 with Positive HIV Status\n \n 2023-03-28 08:43:51 UTC\n \n 2023-03-28 08:54: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 1847\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 \n from obs o \n -- HIV PositiveStatus \n inner join location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \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 having Age < 15\n','2023-03-28 14:13:51',4,'2023-03-28 14:24:04',4,0,NULL,NULL,NULL,'63b6abab-6261-4d20-9601-74454ea10cd6'),(1848,'Miners with Positive HIV Status','High risk population of miners with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Miners with Positive HIV Status\n High risk population of miners with Positive HIV Status\n \n 2023-03-28 08:58:19 UTC\n \n 2023-03-28 09:01: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 1848\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3667 -- Population (Miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 14:28:19',4,'2023-03-28 14:31:36',4,0,NULL,NULL,NULL,'d4d85343-09fc-473b-a650-50f444deee3e'),(1849,'Ex-Miners with Positive HIV Status',' High risk population of Ex Miners with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex-Miners with Positive HIV Status\n High risk population of Ex Miners with Positive HIV Status\n \n 2023-03-28 09:10:47 UTC\n \n 2023-03-28 09:17: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 1849\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3668 -- Population (Ex-Miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 14:40:47',4,'2023-03-28 14:47:26',4,0,NULL,NULL,NULL,'33fa2a02-6cb8-4850-8d80-18d86f0516a8'),(1850,'Pulmonary Clinically Diagnosed Excluding Relapse','Pulmonary Clinically Diagnosed Excluding Relapse','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Clinically Diagnosed Excluding Relapse\n Pulmonary Clinically Diagnosed Excluding Relapse\n \n 2023-03-28 09:16:40 UTC\n \n 2024-05-20 17:12: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 1850\n select distinct Id \n FROM \n -- Clinical Diagnosis X-Ray \n ( \n \n Select distinct person_id as Id, max_observation, examination_timing,o.voided \n from obs o \n inner join \n ( \n select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.obs_id)), 20) as examination_timing \n from obs oss \n where oss.concept_id = 4153 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n and oss.voided = 0 \n group by oss.person_id \n \n )latest \n on latest.Id = o.person_id \n where o.concept_id = 4673 and o.value_coded = 4171 \n and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n and o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Patient must not be a tranfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND (os.obs_datetime BETWEEN :startDate AND :endDate) \n and os.voided = 0 \n ) \n group by Id \n )as XRay_Clients \n \n -- Site (Pulmonary) \n inner join ( \n select distinct ob.person_id as pId \n FROM obs ob \n -- Pulmonary TB \n where ob.concept_id = 3788 and ob.value_coded = 1018 \n AND cast(ob.obs_datetime as date) >= CAST(:startDate AS DATE) \n and cast(ob.obs_datetime as date) <= CAST(:endDate AS DATE) \n and ob.voided = 0 \n group by pId \n ) As Pulmonary \n on XRay_Clients.Id = Pulmonary.pId \n \n inner join ( \n select distinct person_id as pId \n from obs ob \n where ob.concept_id = 3785 and ob.value_coded in (3786,1037,1033) \n and cast(ob.obs_datetime as date) >= :startDate \n and cast(ob.obs_datetime as date) <= :endDate \n \n ) As New_Client \n on XRay_Clients.Id = New_Client.pId\n','2023-03-28 14:46:40',4,'2024-05-20 22:42:25',4,0,NULL,NULL,NULL,'8a1f3d92-c5ec-4892-920b-5bae45020424'),(1851,'Factory Workers with Positive HIV Status','High risk population of Factory Workers with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Workers with Positive HIV Status\n High risk population of Factory Workers with Positive HIV Status\n \n 2023-03-28 09:22:07 UTC\n \n 2023-03-28 09:23: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 1851\n select distinct o.person_id \n from obs o \n -- Positive HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3669 -- Population (Factory Workers) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 14:52:07',4,'2023-03-28 14:53:45',4,0,NULL,NULL,NULL,'e7f0599c-bb8c-4d2d-94a7-4b99e0f1f7af'),(1852,'Public transport with Positive HIV Status','High risk population of Public transport operators with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public transport with Positive HIV Status\n High risk population of Public transport operators with Positive HIV Status\n \n 2023-03-28 09:26:12 UTC\n \n 2023-03-28 09:28: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 1852\n select distinct o.person_id \n from obs o \n -- Positive HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 4654 -- Population (Public transport operators) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 14:56:12',4,'2023-03-28 14:58:18',4,0,NULL,NULL,NULL,'17f9486c-aefe-4a21-b3ad-d5c685280640'),(1853,'Health workers with Positive HIV Status',' High risk population of Health workers with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health workers with Positive HIV Status\n High risk population of Health workers with Positive HIV Status\n \n 2023-03-28 09:31:54 UTC\n \n 2023-03-28 09: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 1853\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 4670 -- Population (Health workers) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 15:01:54',4,'2023-03-28 15:02:36',4,0,NULL,NULL,NULL,'e071852e-15c9-4eb6-92a9-c1c8157db41d'),(1854,'Correctional Staff and inmates with Positive HIV Status','High risk population of Correctional Staff and inmates with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Correctional Staff and inmates with Positive HIV Status\n High risk population of Correctional Staff and inmates with Positive HIV Status\n \n 2023-03-28 09:35:03 UTC\n \n 2023-03-28 09: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 1854\n select distinct o.person_id \n from obs o \n -- Positive HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded in (3779, 3671) -- Population (Correctional Staff and inmates) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 15:05:03',4,'2023-03-28 15:05:43',4,0,NULL,NULL,NULL,'d6df7665-4e94-4ae6-886e-c1fb05a4a0b1'),(1855,'Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - New','Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - New','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - New\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - New\n \n 2023-03-28 10:05:40 UTC\n \n 2023-03-29 16:14: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 1855\n select distinct ob.person_id \n FROM obs ob \ninner join location l on ob.location_id = l.location_id \n \n where ob.concept_id = 3788 and ob.value_coded = 2233 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.person_id in \n ( \n select distinct o.person_id \n \n from obs o \n -- New TB Patient \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n -- TB Start Date \n where ob.concept_id = 2237 \n and ob.value_datetime >= :startDate \n and ob.value_datetime <= :endDate \n and ob.voided = 0 \n ) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- New Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1034 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n ) \n \n \n AND o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Patient must not be a tranfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND (os.obs_datetime BETWEEN :startDate AND :endDate) \n ) \n ) \n and ob.voided = 0 \n or ob.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Extra Pulmonary TB in ART Intake \n where ob.concept_id = 2236 and ob.value_coded = 2233 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n \n','2023-03-28 12:05:40',4,'2023-03-29 18:14:16',4,0,NULL,NULL,NULL,'155d4939-e304-4aa0-a2d4-efc18644affa'),(1856,'HHCM with Documented HIV Status','High risk population of HHCM with Documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM with Documented HIV Status\n High risk population of HHCM with Documented HIV Status\n \n 2023-03-28 10:39:40 UTC\n \n 2023-03-28 10:42: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 1856\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3777 -- Population (Household member of current miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 16:09:40',4,'2023-03-28 16:12:42',4,0,NULL,NULL,NULL,'6584ebef-9d17-4b53-80ba-7396b170919f'),(1857,'HHXM with Documented HIV Status','High risk population of HHXM with Documented HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM with Documented HIV Status\n High risk population of HHXM with Documented HIV Status\n \n 2023-03-28 10:46:20 UTC\n \n 2023-03-28 10:48: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 1857\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3778 -- Population (Household member of Ex miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 16:16:20',4,'2023-03-28 16:18:26',4,0,NULL,NULL,NULL,'f06272eb-e3f7-4d7e-82d1-1e3a391a8b9e'),(1858,'HHCM with Positive HIV Status','High risk population of HHCM with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM with Positive HIV Status\n High risk population of HHCM with Positive HIV Status\n \n 2023-03-28 10:54:07 UTC\n \n 2023-03-28 10:59: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 1858\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3777 -- Population (Household member of current miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 16:24:07',4,'2023-03-28 16:29:14',4,0,NULL,NULL,NULL,'2b06bd4f-a633-48d8-9a9a-12ae5f84001b'),(1859,'HHXM with Positive HIV Status','High risk population of HHXM with Positive HIV Status','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM with Positive HIV Status\n High risk population of HHXM with Positive HIV Status\n \n 2023-03-28 11:03:32 UTC\n \n 2023-03-28 11:08: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 1859\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3778 -- Population (Household member of Ex miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 16:33:32',4,'2023-03-28 16:38:06',4,0,NULL,NULL,NULL,'46bd9d48-49d2-4fd5-b433-f1123f217588'),(1860,'Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Relapse','Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Relapse','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Relapse\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Relapse\n \n 2023-03-28 11:42:29 UTC\n \n 2023-03-29 16:33: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 1860\n select distinct ob.person_id \n FROM obs ob \ninner join location l on ob.location_id = l.location_id \n \n where ob.concept_id = 3788 and ob.value_coded = 2233 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.person_id in \n ( \n select distinct o.person_id \n \n from obs o \n -- New TB Patient \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n -- TB Start Date \n where ob.concept_id = 2237 \n and ob.value_datetime >= :startDate \n and ob.value_datetime <= :endDate \n and ob.voided = 0 \n ) \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- New Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1034 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n ) \n \n \n AND o.person_id not in ( \n select distinct os.person_id \n from obs os \n -- Patient must not be a tranfer in \n where os.concept_id = 3772 and os.value_coded =2095 \n AND (os.obs_datetime BETWEEN :startDate AND :endDate) \n ) \n ) \n and ob.voided = 0 \n or ob.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Extra Pulmonary TB in ART Intake \n where ob.concept_id = 2236 and ob.value_coded = 2233 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n \n','2023-03-28 13:42:29',4,'2023-03-29 18:33:58',4,0,NULL,NULL,NULL,'b2905cf9-63d5-4b7b-9a72-0f76caf70da3'),(1861,'HHXM with HIV Positive on CPT/Dapzone','High risk population of HHXM with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM with HIV Positive on CPT/Dapzone\n High risk population of HHXM with HIV Positive on CPT/Dapzone\n \n 2023-03-28 13:51:41 UTC\n \n 2023-03-28 13:52: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 1861\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3778 -- Population (Household member of Ex miner) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 19:21:41',4,'2023-03-28 19:22:17',4,0,NULL,NULL,NULL,'0133ee85-0abd-494a-86b7-6818670bd37b'),(1862,'Extra-pulmonary (bacteriologically confirmed or clinically diagnosed) - Exlude relapse','Extra-pulmonary (bacteriologically confirmed or clinically diagnosed) - Exlude relapse','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Extra-pulmonary (bacteriologically confirmed or clinically diagnosed) - Exlude relapse\n Extra-pulmonary (bacteriologically confirmed or clinically diagnosed) - Exlude relapse\n \n 2023-03-28 14:29:38 UTC\n \n 2023-03-29 16:36: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 1862\n select distinct ob.person_id \n FROM obs ob \n \ninner join location l on ob.location_id = l.location_id \n \n -- Relapsed TB Client \nWHERE (ob.location_id =:location or parent_location =:location) \nand ob.concept_id = 3788 and ob.value_coded = 2233 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.person_id in \n ( \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.obs_datetime >= :startDate \n and o.obs_datetime <= :endDate \n ) \n and ob.voided = 0 \n or ob.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Extra Pulmonary TB in ART Intake \n where ob.concept_id = 2236 and ob.value_coded = 2233 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n \n','2023-03-28 16:29:38',4,'2023-03-29 18:36:39',4,0,NULL,NULL,NULL,'5023a0c3-15b8-4d16-ac54-09a77d01648d'),(1863,'HHCM with HIV Positive on CPT/Dapzone','High risk population of HHCM with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM with HIV Positive on CPT/Dapzone\n High risk population of HHCM with HIV Positive on CPT/Dapzone\n \n 2023-03-28 15:05:16 UTC\n \n 2023-03-28 15:09: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 1863\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3777 -- Population (Household member of miner) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 20:35:16',4,'2023-03-28 20:39:54',4,0,NULL,NULL,NULL,'6365d73a-6fde-4e27-a75b-b5010023ddea'),(1864,'New and Relapse with HIV Positive on CPT/Dapzone','High risk population of New and Relapse with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse with HIV Positive on CPT/Dapzone\n High risk population of New and Relapse with HIV Positive on CPT/Dapzone\n \n 2023-03-28 15:14:37 UTC\n \n 2023-03-28 15: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 1864\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded in (1034, 1084) -- Population (New and Relapse) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 20:44:37',4,'2023-03-28 20:46:55',4,0,NULL,NULL,NULL,'14343630-0c58-4f34-8bb5-1744e1618c31'),(1865,'Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : New','Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : New','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : New\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : New\n \n 2023-03-28 15:16:26 UTC\n \n 2023-03-29 16:47: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 1865\n select distinct o.person_id \n FROM obs o \ninner join location l on o.location_id = l.location_id \n -- Bacteriologically confirmed Genotypic test results and Phenotypic test results \n where (o.location_id =:location or parent_location =:location) \n and o.concept_id in (3814, 3815) \n and o.obs_datetime >= :startDate \n and o.obs_datetime <= :endDate \n and o.voided = 0 \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- New Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1034 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n ) \n and o.person_id in ( \n select person_id \n from obs where concept_id = 3789 and value_coded= 3791 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n and o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB \n where ob.concept_id = 3788 and ob.value_coded = 1018 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n or o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB, Bacteriologically Confirmed \n where ob.concept_id = 2236 and ob.value_coded = 2234 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n )\n','2023-03-28 17:16:26',4,'2023-03-29 18:47:04',4,0,NULL,NULL,NULL,'273f38fa-7a41-4323-ac9d-24fd27c0c4cf'),(1866,'Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Relapse','Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Relapse','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Relapse\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Relapse\n \n 2023-03-28 15:21:59 UTC\n \n 2023-03-29 16:47: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 1866\n select distinct o.person_id \n FROM obs o \n \ninner join location l on o.location_id = l.location_id \nWHERE (o.location_id =:location or parent_location =:location) \n and o.concept_id in (3814, 3815) \n and o.obs_datetime >= :startDate \n and o.obs_datetime <= :endDate \n and o.voided = 0 \n AND o.person_id in \n ( \n \n -- Relapsed Clients \n select distinct oo.person_id \n from obs oo \n where oo.concept_id = 3785 and oo.value_coded = 1084 \n and oo.obs_datetime >= :startDate \n and oo.obs_datetime <= :endDate \n ) \n and o.person_id in ( \n select person_id \n from obs where concept_id = 3789 and value_coded= 3791 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n and o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB \n where ob.concept_id = 3788 and ob.value_coded = 1018 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n or o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB, Bacteriologically Confirmed \n where ob.concept_id = 2236 and ob.value_coded = 2234 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n )\n','2023-03-28 17:21:59',4,'2023-03-29 18:47:31',4,0,NULL,NULL,NULL,'300b2de6-1987-4ae2-a742-c2907f6bc2b7'),(1867,'Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Excluding Relapse','Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Excluding Relapse','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Excluding Relapse\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Excluding Relapse\n \n 2023-03-28 15:25:40 UTC\n \n 2023-03-30 15:34: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 1867\n select distinct o.person_id \n FROM obs o \ninner join location l on o.location_id = l.location_id \nWHERE (o.location_id =:location or parent_location =:location) \n and o.concept_id in (3814, 3815) \n and o.obs_datetime >= :startDate \n and o.obs_datetime <= :endDate \n and o.voided = 0 \n AND o.person_id in ( \n select person_id from obs \n where concept_id = 3788 and value_coded = 2233 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n \n ) \n AND o.person_id not in \n ( \n \n -- Relapsed Clients \n select distinct person_id \n from obs \n where concept_id = 3785 and value_coded = 1084 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n and o.person_id in ( \n select person_id \n from obs where concept_id = 3789 and value_coded= 3791 \n and obs_datetime >= :startDate \n and obs_datetime <= :endDate \n ) \n and o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB \n where ob.concept_id = 3788 and ob.value_coded = 1018 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n ) \n or o.person_id in ( \n select ob.person_id \n FROM obs ob \n -- Pulmonary TB, Bacteriologically Confirmed \n where ob.concept_id = 2236 and ob.value_coded = 2234 \n and ob.obs_datetime >= :startDate \n and ob.obs_datetime <= :endDate \n and ob.voided = 0 \n )\n','2023-03-28 17:25:40',4,'2023-03-30 17:34:09',4,0,NULL,NULL,NULL,'fc1f07c9-e4d5-4d2f-97fb-98b26e6f66d0'),(1868,'Retreatment with HIV Positive on CPT/Dapzone','Retreatment Excl. Relapse with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment with HIV Positive on CPT/Dapzone\n Retreatment Excl. Relapse with HIV Positive on CPT/Dapzone\n \n 2023-03-28 15:28:13 UTC\n \n 2023-03-28 15:30: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 1868\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded in (3786, 1037) -- Population (Retreatment Excl. Relapse) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 20:58:13',4,'2023-03-28 21:00:05',4,0,NULL,NULL,NULL,'fc64e900-ad46-45b3-9514-3d9aaefbd2cf'),(1869,'Children < 15 with Positive HIV on CPT/Dapzone','Children < 15 with Positive HIV on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children < 15 with Positive HIV on CPT/Dapzone\n Children < 15 with Positive HIV on CPT/Dapzone\n \n 2023-03-28 15:51:27 UTC\n \n 2023-03-29 21:44: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 1869\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 \n from obs o \n -- HIV Positive Status \n inner join location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \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 having Age < 15\n','2023-03-28 17:51:27',4,'2023-03-29 23:44:53',4,0,NULL,NULL,NULL,'36fe954a-f05e-431b-9037-4772a4b28383'),(1870,'Miners with HIV Positive on CPT/Dapzone','High risk population Miners with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Miners with HIV Positive on CPT/Dapzone\n High risk population Miners with HIV Positive on CPT/Dapzone\n \n 2023-03-28 15:55:23 UTC\n \n 2023-03-28 15: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 1870\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3667 -- Population (miner) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 21:25:23',4,'2023-03-28 21:26:49',4,0,NULL,NULL,NULL,'354da83b-27c3-4124-9198-d1902fefb417'),(1871,'Ex Miner with HIV Positive on CPT/Dapzone',' High risk population of Ex Miner with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex Miner with HIV Positive on CPT/Dapzone\n High risk population of Ex Miner with HIV Positive on CPT/Dapzone\n \n 2023-03-28 16:02:40 UTC\n \n 2023-03-28 16:06: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 1871\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3668 -- Population (Ex miner) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 21:32:40',4,'2023-03-28 21:36:28',4,0,NULL,NULL,NULL,'ff703f75-36cc-4487-afab-65df0ccbff68'),(1872,'Factory Workers with HIV Positive on CPT/Dapzone','High risk population of Factory Workers with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Workers with HIV Positive on CPT/Dapzone\n High risk population of Factory Workers with HIV Positive on CPT/Dapzone\n \n 2023-03-28 16:08:16 UTC\n \n 2023-03-28 16:09: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 1872\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3770 -- Population (Factory Workers) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 21:38:16',4,'2023-03-28 21:39:25',4,0,NULL,NULL,NULL,'ff030c28-e12b-45ed-80b0-330e353fdd29'),(1873,'Public transport operators with HIV Positive on CPT/Dapzone','High risk population of Public transport operators with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public transport operators with HIV Positive on CPT/Dapzone\n High risk population of Public transport operators with HIV Positive on CPT/Dapzone\n \n 2023-03-28 16:14:01 UTC\n \n 2023-03-28 16:14: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 1873\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =4654 -- Population (Public transport operators) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 21:44:01',4,'2023-03-28 21:44:45',4,0,NULL,NULL,NULL,'b116d4a0-174f-49a7-be0f-3d5f79581b05'),(1874,'Health workers with HIV Positive on CPT/Dapzone',' High risk population of Health workers with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health workers with HIV Positive on CPT/Dapzone\n High risk population of Health workers with HIV Positive on CPT/Dapzone\n \n 2023-03-28 16:16:21 UTC\n \n 2023-03-28 16:17: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 1874\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3470 -- Population (Health workers) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 21:46:21',4,'2023-03-28 21:47:38',4,0,NULL,NULL,NULL,'4c4aa324-1728-4001-a94e-e857574126b1'),(1875,'Correctional Staff and inmates with HIV Positive on CPT/Dapzone','High risk population of Correctional Staff and inmates with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Correctional Staff and inmates with HIV Positive on CPT/Dapzone\n High risk population of Correctional Staff and inmates with HIV Positive on CPT/Dapzone\n \n 2023-03-28 16:20:31 UTC\n \n 2023-03-28 16:27: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 1875\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded in (3779, 3671) -- Population (Correctional Staff and inmates) \n AND ob.voided = 0 \n \n ) \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 5415 and ob.value_coded in (2330,4619) -- On Dapsone/CPT AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-28 21:50:31',4,'2023-03-28 21:57:26',4,0,NULL,NULL,NULL,'423a7240-f359-41a2-929d-7b1cd7010807'),(1876,'TB among Miners','TB among Key Population Group Miners','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Miners\n TB among Key Population Group Miners\n \n 2023-03-28 17:11:27 UTC\n \n 2023-03-28 17:34: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 1876\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- Miners \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- Miners \n select distinct person_id \n from obs \n where concept_id = 3776 and value_coded = 3667 \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) AS Miner \n)\n','2023-03-28 22:41:27',4,'2023-03-28 23:04:23',4,0,NULL,NULL,NULL,'273e3515-f928-4164-be82-fc5235d66188'),(1877,'TB among Exminers','TB among Key Population Group Exminers','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Exminers\n TB among Key Population Group Exminers\n \n 2023-03-28 17:40:01 UTC\n \n 2023-03-28 17: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 1877\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- Exminers \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- Exminers \n select distinct person_id \n from obs \n where concept_id = 3776 and value_coded = 3668 \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) AS Exminer \n)\n','2023-03-28 23:10:01',4,'2023-03-28 23:11:15',4,0,NULL,NULL,NULL,'ecb47cb2-6af4-4932-8fee-076ba40afa87'),(1878,'TB among HHCM','TB among Key Population Group HHCM','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among HHCM\n TB among Key Population Group HHCM\n \n 2023-03-28 19:19:59 UTC\n \n 2023-03-28 19:26: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 1878\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- HHCM \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- HHCM \n select distinct person_id \n from obs \n where concept_id = 3776 and value_coded = 3777 \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) As HHCM \n)\n','2023-03-29 00:49:59',4,'2023-03-29 00:56:17',4,0,NULL,NULL,NULL,'0da939c1-ae87-45c8-80ed-e56b82e5a62e'),(1879,'Correctional Staff and inmates on HIV Positive on ART','High risk population of Correctional Staff and inmates on HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Correctional Staff and inmates on HIV Positive on ART\n High risk population of Correctional Staff and inmates on HIV Positive on ART\n \n 2023-03-28 19:25:59 UTC\n \n 2023-03-29 20: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 1879\n select distinct o.person_id \n from obs o \n -- On ART \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded in (3779, 3671) -- Population (Correctional Staff and inmates) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \nAND o.obs_datetime >= CAST(:endDate AS DATE) \n\n','2023-03-28 21:25:59',4,'2023-03-29 22:58:43',4,0,NULL,NULL,NULL,'a6ebd7a8-631b-4e0e-bdfb-8be1b9fb9eec'),(1880,'New and Relapse with HIV Positive on ART','High risk population of New and Relapse with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse with HIV Positive on ART\n High risk population of New and Relapse with HIV Positive on ART\n \n 2023-03-28 19:29:52 UTC\n \n 2023-03-28 19:32: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 1880\n SELECT DISTINCT o.person_id \n from obs o \n -- New and Relapse On ART \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3785 and ob.value_coded in (1034, 1084) -- New and Relapse \n and ob.voided = 0 \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE)\n','2023-03-29 00:59:52',4,'2023-03-29 01:02:02',4,0,NULL,NULL,NULL,'8067c849-4c81-475a-a26e-68a2e58b8067'),(1882,'Retreatment with HIV Positive on ART','High risk population of Retreatment Excl. Relapse HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment with HIV Positive on ART\n High risk population of Retreatment Excl. Relapse HIV Positive on ART\n \n 2023-03-28 19:34:51 UTC\n \n 2023-03-28 19:45: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 1882\n SELECT DISTINCT o.person_id \n from obs o \n -- Retreatmentafter LTFU/Failure on ART \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3785 and ob.value_coded in (3786, 1037) -- Retreatmentafter LTFU/Failure \n and ob.voided = 0 \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-29 01:04:51',4,'2023-03-29 01:15:46',4,0,NULL,NULL,NULL,'fe4f73c9-4b24-4458-9ae1-9d3fcad9f9cb'),(1883,'TB among HHXM','TB among Key Population Group HHXM','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among HHXM\n TB among Key Population Group HHXM\n \n 2023-03-28 19:35:03 UTC\n \n 2023-03-28 19:37: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 1883\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- HHXM \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- HHXM \n select distinct person_id \n from obs \n where concept_id = 3776 and value_coded = 3778 \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) AS HHXM \n)\n','2023-03-29 01:05:03',4,'2023-03-29 01:07:06',4,0,NULL,NULL,NULL,'4715bb07-7b64-4001-b5cb-ea555b425a07'),(1884,'TB among Factory Workers','TB among Key Population Group Factory Workers','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Factory Workers\n TB among Key Population Group Factory Workers\n \n 2023-03-28 19:43:14 UTC\n \n 2023-03-28 19:45:00 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 1884\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- FactoryWorkers \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- FactoryWorkers \n select distinct person_id \n from obs \n where concept_id = 3776 and value_coded = 3669 \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) AS FactoryWorkers \n)\n','2023-03-29 01:13:14',4,'2023-03-29 01:15:01',4,0,NULL,NULL,NULL,'6bed2c03-ba40-477b-9a9a-67f3fcd50ea3'),(1885,'TB among Correctional Staff & Inmates','TB among Key Population Group Correctional Staff & Inmates','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Correctional Staff & Inmates\n TB among Key Population Group Correctional Staff & Inmates\n \n 2023-03-28 19:47:06 UTC\n \n 2023-03-28 19:49: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 1885\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- Correctional Staff & Inmates \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- Correctional Staff & Inmates \n select distinct person_id \n from obs \n where concept_id = 3776 and value_coded in (3779,3671) \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) AS Correctional \n)\n','2023-03-29 01:17:06',4,'2023-03-29 01:19:30',4,0,NULL,NULL,NULL,'9016d0ef-4556-49e7-99bd-2bf2e7f5188f'),(1886,'Children < 15 with HIV Positive on ART','High risk population for Children < 15 with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children < 15 with HIV Positive on ART\n High risk population for Children < 15 with HIV Positive on ART\n \n 2023-03-28 19:47:46 UTC\n \n 2023-03-28 19:50: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 1886\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 \n from obs o \n -- HIV Positive on ART \n inner join location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \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 having Age < 15\n','2023-03-29 01:17:46',4,'2023-03-29 01:20:02',4,0,NULL,NULL,NULL,'e724e30e-b9e1-4a19-afa9-d19aa8dc42f4'),(1887,'TB among Public Transport Operators ','TB among Key Population Group Public Transport Operators','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Public Transport Operators \n TB among Key Population Group Public Transport Operators\n \n 2023-03-28 19:51:36 UTC\n \n 2023-03-28 19:53: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 1887\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- Transport \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- Transport \n select distinct person_id \n from obs \n where concept_id = 3776 and value_coded = 4654 \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) AS Transport \n)\n','2023-03-29 01:21:36',4,'2023-03-29 01:23:32',4,0,NULL,NULL,NULL,'4aac5017-e28a-4f36-8805-0812476a9d7b'),(1888,'Miners with HIV Positive on ART','High risk population of Miners with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Miners with HIV Positive on ART\n High risk population of Miners with HIV Positive on ART\n \n 2023-03-28 19:55:27 UTC\n \n 2023-03-28 19:56: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 1888\n select distinct o.person_id \n from obs o \n -- HIV Positive on ART \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 and o.value_coded in (4323, 4664) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3667 -- Population (Miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-29 01:25:27',4,'2023-03-29 01:26:16',4,0,NULL,NULL,NULL,'a37a95b7-1365-4d73-8d21-28dd2e77196e'),(1889,'TB among Health Workers','TB among Key Population Group Health Workers','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Health Workers\n TB among Key Population Group Health Workers\n \n 2023-03-28 19:55:49 UTC\n \n 2023-03-28 19:57: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 1889\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 Id, patientIdentifier AS "Patient_Identifier", patientName AS "Patient_Name" \n FROM \n \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 -- HealthWorkers \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in \n ( \n select distinct ob.person_id \n from obs ob \n where ob.person_id in ( \n -- HealthWorkers \n select distinct person_id \n from obs \n where concept_id = 3776 and value_coded = 3670 \n and obs_datetime >= CAST(:startDate AS DATE) \n and obs_datetime <= CAST(:endDate AS DATE) \n ) \n ) \n \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 \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 NEW_TB_CLIENTS \n ORDER BY NEW_TB_CLIENTS.Age) \n \n) AS HealthWorkers \n)\n','2023-03-29 01:25:49',4,'2023-03-29 01:27:20',4,0,NULL,NULL,NULL,'04590a3f-4e59-45fe-a5c3-f5ae76ef805b'),(1890,'Ex Miner with with HIV Positive on ART','High risk population of Ex Miner with with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex Miner with with HIV Positive on ART\n High risk population of Ex Miner with with HIV Positive on ART\n \n 2023-03-28 19:58:00 UTC\n \n 2023-03-28 19:59: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 1890\n select distinct o.person_id \n from obs o \n -- HIV Positive on ART \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3668 -- Population (Ex-Miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-29 01:28:00',4,'2023-03-29 01:29:01',4,0,NULL,NULL,NULL,'1edf0f21-2fad-48c7-a24a-e21367f334c1'),(1891,'HHCM with with HIV Positive on ART','High risk population of HHCM with with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM with with HIV Positive on ART\n High risk population of HHCM with with HIV Positive on ART\n \n 2023-03-28 20:00:28 UTC\n \n 2023-03-28 20:03: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 1891\n select distinct o.person_id \n from obs o \n -- HIV Positive on ART \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3777 -- Population (Household member of current miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-29 01:30:28',4,'2023-03-29 01:33:58',4,0,NULL,NULL,NULL,'14b8879f-49ef-492c-aeb0-fdd62fde084a'),(1892,'TB among Miners','TB among Key Population Group Miners','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Miners\n TB among Key Population Group Miners\n \n 2023-03-28 20:05:03 UTC\n \n 2023-03-28 20:12: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 1892\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 01:35:03',4,'2023-03-29 01:42:22',4,0,NULL,NULL,NULL,'526100b3-2b2a-4f15-862e-4be06d73bdb3'),(1893,'HHXM with HIV Positive on ART','High risk population of HHXM with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM with HIV Positive on ART\n High risk population of HHXM with HIV Positive on ART\n \n 2023-03-28 20:05:19 UTC\n \n 2023-03-28 20: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 1893\n select distinct o.person_id \n from obs o \n -- Positive, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded =3778 -- Population (Household member of Ex miner) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-29 01:35:19',4,'2023-03-29 01:38:02',4,0,NULL,NULL,NULL,'0d7e9652-b8fa-4264-859b-0b681452c462'),(1894,'Factory Workers with HIV Positive on ART','High risk population of Factory Workers with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Workers with HIV Positive on ART\n High risk population of Factory Workers with HIV Positive on ART\n \n 2023-03-28 20:09:30 UTC\n \n 2023-03-28 20:10: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 1894\n select distinct o.person_id \n from obs o \n -- Positive HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 3669 -- Population (Factory Workers) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-29 01:39:30',4,'2023-03-29 01:40:27',4,0,NULL,NULL,NULL,'67233a82-27bf-4615-948b-28fad7ad6322'),(1895,'Public transport operators with HIV Positive on ART','High risk population of Public transport operators with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public transport operators with HIV Positive on ART\n High risk population of Public transport operators with HIV Positive on ART\n \n 2023-03-28 20:12:15 UTC\n \n 2023-03-28 20:14: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 1895\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4666 \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 4654 -- Population (Public transport operators) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-29 01:42:15',4,'2023-03-29 01:44:34',4,0,NULL,NULL,NULL,'63418340-29fe-4106-83ad-a09538397f5f'),(1896,'TB among Exminers','TB among Key Population Group Ex Miners','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Exminers\n TB among Key Population Group Ex Miners\n \n 2023-03-28 20:13:33 UTC\n \n 2023-03-28 20: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 1896\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 01:43:33',4,'2023-03-29 01:48:09',4,0,NULL,NULL,NULL,'2dcbfff3-70b6-4ed5-b727-a51fea71b8aa'),(1897,'Health workers with HIV Positive on ART','High risk population of Health workers with HIV Positive on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health workers with HIV Positive on ART\n High risk population of Health workers with HIV Positive on ART\n \n 2023-03-28 20:18:06 UTC\n \n 2023-03-28 20:18: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 1897\n select distinct o.person_id \n from obs o \n -- Documented HIV, Status \n INNER JOIN location l on o.location_id = l.location_id \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.concept_id = 4667 and o.value_coded in (4670, 4669) \n AND o.voided = 0 \n AND o.person_id in \n ( \n Select ob.person_id \n from obs ob \n where ob.concept_id = 3776 and ob.value_coded = 4670 -- Population (Health workers) \n AND ob.voided = 0 \n \n ) \n AND o.obs_datetime >= CAST(:startDate AS DATE) \n AND o.obs_datetime <= CAST(:endDate AS DATE) \n','2023-03-29 01:48:06',4,'2023-03-29 01:48:39',4,0,NULL,NULL,NULL,'1340548d-896a-4473-ae26-4c8960dec630'),(1898,'TB among HHCM','TB among Key Population Group HHCM','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among HHCM\n TB among Key Population Group HHCM\n \n 2023-03-28 20:19:17 UTC\n \n 2023-03-28 20:20: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 1898\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 01:49:17',4,'2023-03-29 01:50:21',4,0,NULL,NULL,NULL,'dd0ada55-f903-426e-a60e-f83ceeb15cab'),(1899,'TB among HHXM','TB among Key Population Group HHXM','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among HHXM\n TB among Key Population Group HHXM\n \n 2023-03-28 20:21:08 UTC\n \n 2023-03-28 20:23: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 1899\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 01:51:08',4,'2023-03-29 01:53:24',4,0,NULL,NULL,NULL,'9558eb96-47f5-4cdd-ad4f-d07257529259'),(1900,'Pulmonary Bacteriologically Confirmed - Exlude Relapse','Pulmonary Bacteriologically Confirmed - Exlude Relapse','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Bacteriologically Confirmed - Exlude Relapse\n Pulmonary Bacteriologically Confirmed - Exlude Relapse\n \n 2023-03-29 03:39:55 UTC\n \n 2023-03-29 17:21: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 1900\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 05:39:55',4,'2023-03-29 19:21:25',4,0,NULL,NULL,NULL,'8315a536-5b6e-4da8-bcf7-860b6b6bd8aa'),(1902,'Pulmonary Bacteriologically Confirmed New','Pulmonary Bacteriologically Confirmed New','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Bacteriologically Confirmed New\n Pulmonary Bacteriologically Confirmed New\n \n 2023-03-29 04:12:11 UTC\n \n 2023-03-29 05:37: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 1902\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 09:42:11',4,'2023-03-29 11:07:28',4,0,NULL,NULL,NULL,'15e06979-0f27-4aba-87fb-bc5a6dc28da4'),(1903,'Pulmonary Clinically Diagnosed Excluding Relapse','Pulmonary Clinically Diagnosed Excluding Relapse','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Clinically Diagnosed Excluding Relapse\n Pulmonary Clinically Diagnosed Excluding Relapse\n \n 2023-03-29 06:06:35 UTC\n \n 2023-03-29 08:12: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 1903\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 11:36:35',4,'2023-03-29 13:42:28',4,0,NULL,NULL,NULL,'b0ff3ba5-25df-46e4-8eae-bfca7d86b9dd'),(1904,'Pulmonary Bacteriologically Confirmed Relapse','Pulmonary Bacteriologically Confirmed Relapse','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Bacteriologically Confirmed Relapse\n Pulmonary Bacteriologically Confirmed Relapse\n \n 2023-03-29 06:08:27 UTC\n \n 2023-03-29 08:11: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 1904\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 11:38:27',4,'2023-03-29 13:41:19',4,0,NULL,NULL,NULL,'f6797c59-e7e3-4492-ad5f-a67bf5e683bc'),(1905,'Pulmonary Clinically Diagnosed New','Pulmonary Clinically Diagnosed New','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Clinically Diagnosed New\n Pulmonary Clinically Diagnosed New\n \n 2023-03-29 08:14:51 UTC\n \n 2023-03-29 08:17: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 1905\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 13:44:51',4,'2023-03-29 13:47:31',4,0,NULL,NULL,NULL,'63333694-f766-4047-830b-087496f8e5a8'),(1906,'Pulmonary Clinically Diagnosed Relapse','Pulmonary Clinically Diagnosed Relapse','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pulmonary Clinically Diagnosed Relapse\n Pulmonary Clinically Diagnosed Relapse\n \n 2023-03-29 08:15:08 UTC\n \n 2023-03-29 08: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 1906\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 13:45:08',4,'2023-03-29 13:48:31',4,0,NULL,NULL,NULL,'2ff007c1-993d-48fc-8df6-9ed7c66b42d3'),(1907,'Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - New','Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - New','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - New\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - New\n \n 2023-03-29 08:25:10 UTC\n \n 2023-03-29 08:49: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 1907\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 13:55:10',4,'2023-03-29 14:19:47',4,0,NULL,NULL,NULL,'d1ce1a2c-338a-4926-a1d4-f7f79ac2b875'),(1908,'TB among Factory Workers','TB among Key Population Group Factory Workers','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Factory Workers\n TB among Key Population Group Factory Workers\n \n 2023-03-29 08:26:00 UTC\n \n 2023-03-29 08:52: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 1908\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-03-29 13:56:00',4,'2023-03-29 14:22:40',4,0,NULL,NULL,NULL,'071a7d7a-f944-4965-978c-bfe740051b9a'),(1909,'Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Relapse','Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Relapse','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Relapse\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Relapse\n \n 2023-03-29 08:52:39 UTC\n \n 2023-03-29 08:54: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 1909\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 14:22:39',4,'2023-03-29 14:24:28',4,0,NULL,NULL,NULL,'20c9a6fc-f845-4569-b018-b5f59c39948c'),(1910,'Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Excluging Relapse','Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Excluging Relapse','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Excluging Relapse\n Extra Pulmonary : (bacteriologically confirmed or clinically diagnosed) - Excluging Relapse\n \n 2023-03-29 08:53:19 UTC\n \n 2023-03-29 08:54: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 1910\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 14:23:19',4,'2023-03-29 14:24:54',4,0,NULL,NULL,NULL,'422afe85-5763-4700-8a8b-bf17328901a8'),(1911,'TB among Correctional Staff & Inmates','TB among Key Population Group Correctional Staff & Inmates','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Correctional Staff & Inmates\n TB among Key Population Group Correctional Staff & Inmates\n \n 2023-03-29 08:53:58 UTC\n \n 2023-03-29 08:56: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 1911\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 14:23:58',4,'2023-03-29 14:26:06',4,0,NULL,NULL,NULL,'8ac11f64-421a-4f48-9ac3-048ee6912eda'),(1912,'Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Excluding Relapse','Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Excluding Relapse','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Excluding Relapse\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Excluding Relapse\n \n 2023-03-29 08:55:36 UTC\n \n 2023-03-29 09:04: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 1912\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 14:25:36',4,'2023-03-29 14:34:23',4,0,NULL,NULL,NULL,'83125cb9-0324-4e21-8f4d-b9fd51049909'),(1913,'TB among Public Transport Operators ','TB among Key Population Group Public Transport Operators','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Public Transport Operators \n TB among Key Population Group Public Transport Operators\n \n 2023-03-29 08:57:05 UTC\n \n 2023-03-29 08:59: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 1913\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 14:27:05',4,'2023-03-29 14:29:07',4,0,NULL,NULL,NULL,'f3aabc74-880c-4502-94af-ff9fd0b95906'),(1914,'Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : New','Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : New','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : New\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : New\n \n 2023-03-29 08:59:37 UTC\n \n 2023-03-29 09:04: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 1914\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 14:29:37',4,'2023-03-29 14:34:54',4,0,NULL,NULL,NULL,'c5e34544-e98f-42ce-82d1-3708ce5e5b80'),(1915,'TB among Health Workers','TB among Key Population Group Health Workers','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB among Health Workers\n TB among Key Population Group Health Workers\n \n 2023-03-29 09:02:15 UTC\n \n 2023-03-29 09: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 1915\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 14:32:15',4,'2023-03-29 14:34:59',4,0,NULL,NULL,NULL,'76adf56b-486f-4a4c-b309-5c43372d94eb'),(1916,'TB Notification - Block 3','TB Notification - Block 3','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Notification - Block 3\n TB Notification - Block 3\n \n 2023-03-29 09:08:01 UTC\n \n 2023-03-29 09:08: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 1916\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-03-29 14:38:01',4,'2023-03-29 14:38:31',4,0,NULL,NULL,NULL,'5a51f412-3b6f-4808-ae32-ed90141bb7e2'),(1917,'TB Notification - Block 3 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 Notification - Block 3 Data Set\n \n 2023-03-29 09:08:31 UTC\n \n 2023-03-29 10: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 1917\n \n \n \n TB-HHCM\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 TB-HHXM\n \n \n \n \n \n \n \n \n \n TBExMiners\n \n \n \n \n \n \n \n \n \n TBFactoryW\n \n \n \n \n \n \n \n \n \n TBHealthW\n \n \n \n \n \n \n \n \n \n TBInmates\n \n \n \n \n \n \n \n \n \n TBMiners\n \n \n \n \n \n \n \n \n \n TBTrans\n \n \n \n \n \n \n \n \n \n','2023-03-29 14:38:31',4,'2023-03-29 15:38:22',4,0,NULL,NULL,NULL,'4e91ef91-ad5f-4717-b782-9ac61d52dc40'),(1919,'Block 1: All TB Patients diagnosed with TB during the current quarter, by history of treatment and anatomic site of disease Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Block 1: All TB Patients diagnosed with TB during the current quarter, by history of treatment and anatomic site of disease Data Set\n \n 2023-03-29 09:46:48 UTC\n \n 2023-03-29 15:30: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 1919\n \n \n \n died1\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 died2\n \n \n \n \n \n \n \n \n \n died3\n \n \n \n \n \n \n \n \n \n extra1\n \n \n \n \n \n \n \n \n \n extra2\n \n \n \n \n \n \n \n \n \n extra3\n \n \n \n \n \n \n \n \n \n pul_ExPulm\n \n \n \n \n \n \n \n \n \n pul_clin1\n \n \n \n \n \n \n \n \n \n pul_diag2\n \n \n \n \n \n \n \n \n \n pul_new \n \n \n \n \n \n \n \n \n \n pul_newex\n \n \n \n \n \n \n \n \n \n pul_relaps\n \n \n \n \n \n \n \n \n \n','2023-03-29 11:46:48',4,'2023-03-29 17:30:32',4,0,NULL,NULL,NULL,'b7c3203a-888a-4139-9c3f-e9a8939bc811'),(1920,'New and Relapse with document HIV Status','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse with document HIV Status\n \n \n 2023-03-29 14:22:45 UTC\n \n 2023-03-29 14:30: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 1920\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 19:52:45',4,'2023-03-29 20:00:02',4,0,NULL,NULL,NULL,'18152a92-ded2-4f5a-af93-5dd01b51c839'),(1921,'Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Relapse','Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Relapse','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Relapse\n Bacteriologically confirmed not started on treatment (m) ticked Died before treatment or Lost to follow up : Relapse\n \n 2023-03-29 15:26:50 UTC\n \n 2023-03-29 15:28: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 1921\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 17:26:50',4,'2023-03-29 17:28:11',4,0,NULL,NULL,NULL,'61cb2cc7-ee32-4da9-9c82-7bbc85f3e43c'),(1922,'TB Notification - Block 1 ','TB Notification - Block 1 ','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Notification - Block 1 \n TB Notification - Block 1 \n \n 2023-03-29 17:06:10 UTC\n \n 2023-03-29 17:06: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 1922\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-03-29 19:06:10',4,'2023-03-29 19:06:58',4,0,NULL,NULL,NULL,'c7604f80-13cf-4773-abf5-b95f35fa1c92'),(1923,'TB Notification - 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 Notification - Block 1 Data Set\n \n 2023-03-29 17:06:58 UTC\n \n 2024-05-20 17:33: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 1923\n \n \n \n DieBLTF-Nw\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 DieBLTF-Re\n \n \n \n \n \n \n \n \n \n DieBLTF-XR\n \n \n \n \n \n \n \n \n \n PulBacNew\n \n \n \n \n \n \n \n \n \n PulBacRel\n \n \n \n \n \n \n \n \n \n PulBacXRe\n \n \n \n \n \n \n \n \n \n PulCliDiNw\n \n \n \n \n \n \n \n \n \n PulCliDiXR\n \n \n \n \n \n \n XPulCliDRe\n \n \n \n \n \n \n \n \n \n XPulCliDXP\n \n \n \n \n \n \n \n \n \n XPulCliDXR\n \n \n \n \n \n \n \n \n \n','2023-03-29 22:36:58',4,'2024-05-20 23:03:36',4,0,NULL,NULL,NULL,'d74aa49a-aa20-49e1-939a-5f1fb0c78d81'),(1924,'Children < 15 with Documented HIV Status','Children (0 - 14) with documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children < 15 with Documented HIV Status\n Children (0 - 14) with documented HIV Status\n \n 2023-03-29 17:07:40 UTC\n \n 2023-03-29 17:08: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 1924\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-03-29 19:07:40',4,'2023-03-29 19:08:45',4,0,NULL,NULL,NULL,'777854f8-1e75-4b4c-9eb5-2b2a23acd1fd'),(1925,'Correctional Staff and inmates with Documented HIV Status','High risk population of Correctional Staff and inmates with Documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Correctional Staff and inmates with Documented HIV Status\n High risk population of Correctional Staff and inmates with Documented HIV Status\n \n 2023-03-29 17:11:52 UTC\n \n 2023-03-29 17:16: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 1925\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 19:11:52',4,'2023-03-29 19:16:20',4,0,NULL,NULL,NULL,'8e2ae589-9a13-4aa5-bf9d-3cf376a59bf6'),(1926,'Ex-Miners with Documented HIV Status','High risk population of Ex Miners with Documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex-Miners with Documented HIV Status\n High risk population of Ex Miners with Documented HIV Status\n \n 2023-03-29 17:20:28 UTC\n \n 2023-03-29 17:23: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 1926\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 19:20:28',4,'2023-03-29 19:23:06',4,0,NULL,NULL,NULL,'b2541e20-b6b8-4985-bd4a-9a980ee5ebf8'),(1927,'Factory Workers with Documented HIV Status','High risk population of Factory Workers with Documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Workers with Documented HIV Status\n High risk population of Factory Workers with Documented HIV Status\n \n 2023-03-29 17:25:11 UTC\n \n 2023-03-29 17:29: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 1927\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 19:25:11',4,'2023-03-29 19:29:17',4,0,NULL,NULL,NULL,'e95e9d48-01d5-4826-ab2c-82dbd2dfce44'),(1928,'Health workers with Documented HIV Status','High risk population of Health workers with Documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health workers with Documented HIV Status\n High risk population of Health workers with Documented HIV Status\n \n 2023-03-29 17:31:28 UTC\n \n 2023-03-29 17:33: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 1928\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 19:31:28',4,'2023-03-29 19:33:36',4,0,NULL,NULL,NULL,'38dd8693-21f8-40c2-ba3a-9f5d1a63959c'),(1929,'HHCM with Documented HIV Status','High risk population of HHCM with Documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM with Documented HIV Status\n High risk population of HHCM with Documented HIV Status\n \n 2023-03-29 17:34:59 UTC\n \n 2023-03-29 17:36: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 1929\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 19:34:59',4,'2023-03-29 19:36:32',4,0,NULL,NULL,NULL,'12a86c02-9e39-4d69-8082-ecff9269d106'),(1930,'Miners with Documented HIV Status','High risk population of miners with documented HIV','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Miners with Documented HIV Status\n High risk population of miners with documented HIV\n \n 2023-03-29 17:39:04 UTC\n \n 2023-03-29 17: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 1930\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 19:39:04',4,'2023-03-29 19:42:27',4,0,NULL,NULL,NULL,'625cc3fd-4dc5-4aee-9fba-2559b31470c8'),(1931,'Public transport operators with Documented HIV Status','High risk population of Public transport operators with Documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public transport operators with Documented HIV Status\n High risk population of Public transport operators with Documented HIV Status\n \n 2023-03-29 19:32:07 UTC\n \n 2023-03-29 19: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 1931\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 21:32:07',4,'2023-03-29 21:33:35',4,0,NULL,NULL,NULL,'9e48b5ef-99df-44e7-8946-2728727e08a1'),(1932,'Retreatment with documented HIV status','Retreatment Excl. Relapse client with documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment with documented HIV status\n Retreatment Excl. Relapse client with documented HIV Status\n \n 2023-03-29 19:35:36 UTC\n \n 2023-03-29 19:36: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 1932\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 21:35:36',4,'2023-03-29 21:36:55',4,0,NULL,NULL,NULL,'5cc834ec-7c90-4063-b684-2c9da8ddc83e'),(1933,'Children < 15 with Positive HIV Status','High risk population for Children < 15 with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children < 15 with Positive HIV Status\n High risk population for Children < 15 with Positive HIV Status\n \n 2023-03-29 19:40:57 UTC\n \n 2023-03-29 19:42: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 1933\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 21:40:57',4,'2023-03-29 21:42:25',4,0,NULL,NULL,NULL,'9ceb1ec0-0b28-49d8-a6ba-90297cae2968'),(1934,'Correctional Staff and inmates with Positive HIV Status',' High risk population of Correctional Staff and inmates with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Correctional Staff and inmates with Positive HIV Status\n High risk population of Correctional Staff and inmates with Positive HIV Status\n \n 2023-03-29 19:44:28 UTC\n \n 2023-03-29 19:45: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 1934\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 21:44:28',4,'2023-03-29 21:45:44',4,0,NULL,NULL,NULL,'c9be5185-942d-41ae-8e15-c3ddea7bb22f'),(1935,'Ex-Miners with Positive HIV Status','High risk population of Ex Miners with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex-Miners with Positive HIV Status\n High risk population of Ex Miners with Positive HIV Status\n \n 2023-03-29 19:47:14 UTC\n \n 2023-03-29 19:50: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 1935\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 21:47:14',4,'2023-03-29 21:50:01',4,0,NULL,NULL,NULL,'51933c5f-9020-417a-91fe-77cb0412d9ee'),(1936,'Factory Workers with Positive HIV Status','High risk population of Factory Workers with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Workers with Positive HIV Status\n High risk population of Factory Workers with Positive HIV Status\n \n 2023-03-29 19:52:48 UTC\n \n 2023-03-29 19:56: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 1936\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 21:52:48',4,'2023-03-29 21:56:43',4,0,NULL,NULL,NULL,'a72725b5-eac8-4f97-b285-3a9db174ab39'),(1937,'Health workers with Positive HIV Status',' High risk population of Health workers with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health workers with Positive HIV Status\n High risk population of Health workers with Positive HIV Status\n \n 2023-03-29 19:59:20 UTC\n \n 2023-03-29 20:04: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 1937\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 21:59:20',4,'2023-03-29 22:04:12',4,0,NULL,NULL,NULL,'317c0cce-c0d7-44da-9272-62cc9279a76c'),(1938,'HHCM with Positive HIV Status',' High risk population of HHCM with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM with Positive HIV Status\n High risk population of HHCM with Positive HIV Status\n \n 2023-03-29 20:05:19 UTC\n \n 2023-03-29 20:09: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 1938\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 22:05:19',4,'2023-03-29 22:09:51',4,0,NULL,NULL,NULL,'7a7dee7e-a318-4819-96e9-a1c8fe3e0a4f'),(1939,'HHXM with Positive HIV Status','High risk population of HHXM with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM with Positive HIV Status\n High risk population of HHXM with Positive HIV Status\n \n 2023-03-29 20:10:54 UTC\n \n 2023-03-29 20:11: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 1939\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 22:10:54',4,'2023-03-29 22:11:59',4,0,NULL,NULL,NULL,'4a4bc063-3233-4b3f-9776-8949a2a3104c'),(1940,'Miners with Positive HIV Status','High risk population of miners with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Miners with Positive HIV Status\n High risk population of miners with Positive HIV Status\n \n 2023-03-29 20:13:09 UTC\n \n 2023-03-29 20:15: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 1940\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 22:13:09',4,'2023-03-29 22:15:52',4,0,NULL,NULL,NULL,'a555cd0b-41bf-4ba0-bc0a-bb84952305d7'),(1941,'New and Relapse with Positive HIV Status','New and Relapse with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse with Positive HIV Status\n New and Relapse with Positive HIV Status\n \n 2023-03-29 20:17:12 UTC\n \n 2023-03-29 20:37: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 1941\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 22:17:12',4,'2023-03-29 22:37:39',4,0,NULL,NULL,NULL,'5212b24d-abdf-416a-812e-72b4f64b342d'),(1942,'Public transport with Positive HIV Status','High risk population of Public transport operators with Positive HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public transport with Positive HIV Status\n High risk population of Public transport operators with Positive HIV Status\n \n 2023-03-29 20:38:50 UTC\n \n 2023-03-29 20:39: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 1942\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 22:38:50',4,'2023-03-29 22:39:44',4,0,NULL,NULL,NULL,'3ada2309-e8f6-4301-ae89-63837fb6f36b'),(1943,'Retreatment with Positive HIV status','Retreatment Excl. Relapse with Positive HIV status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment with Positive HIV status\n Retreatment Excl. Relapse with Positive HIV status\n \n 2023-03-29 20:41:12 UTC\n \n 2023-03-29 20:42: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 1943\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 22:41:12',4,'2023-03-29 22:42:06',4,0,NULL,NULL,NULL,'ee1b5901-9777-44c1-affd-37e3aba4746a'),(1944,'Children < 15 with HIV Positive on ART','High risk population for Children < 15 with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children < 15 with HIV Positive on ART\n High risk population for Children < 15 with HIV Positive on ART\n \n 2023-03-29 20:43:47 UTC\n \n 2023-03-29 20:55: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 1944\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 22:43:47',4,'2023-03-29 22:55:26',4,0,NULL,NULL,NULL,'f636be9d-0527-4054-9822-6ab005267560'),(1945,'Correctional Staff and inmates on HIV Positive on ART','High risk population of Correctional Staff and inmates on HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Correctional Staff and inmates on HIV Positive on ART\n High risk population of Correctional Staff and inmates on HIV Positive on ART\n \n 2023-03-29 20:56:54 UTC\n \n 2023-03-29 20: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 1945\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 22:56:54',4,'2023-03-29 22:59:44',4,0,NULL,NULL,NULL,'2c07cd7e-cc23-4974-9964-602e576ef80d'),(1946,'Ex Miner with with HIV Positive on ART','High risk population of Ex Miner with with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex Miner with with HIV Positive on ART\n High risk population of Ex Miner with with HIV Positive on ART\n \n 2023-03-29 21:01:08 UTC\n \n 2023-03-29 21:05: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 1946\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:01:08',4,'2023-03-29 23:05:53',4,0,NULL,NULL,NULL,'8df71093-9cb8-4d1d-9885-fb4415f8c1b2'),(1947,'Factory Workers with HIV Positive on ART','High risk population of Factory Workers with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Workers with HIV Positive on ART\n High risk population of Factory Workers with HIV Positive on ART\n \n 2023-03-29 21:07:39 UTC\n \n 2023-03-29 21:11: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 1947\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:07:39',4,'2023-03-29 23:11:51',4,0,NULL,NULL,NULL,'6d1a75ee-e860-483d-ad80-4308d1009c22'),(1948,'Health workers with HIV Positive on ART',' High risk population of Health workers with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health workers with HIV Positive on ART\n High risk population of Health workers with HIV Positive on ART\n \n 2023-03-29 21:13:26 UTC\n \n 2023-03-29 21:17: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 1948\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:13:26',4,'2023-03-29 23:17:08',4,0,NULL,NULL,NULL,'b3813228-7114-4e37-b997-6acebccd724a'),(1949,'HHCM with with HIV Positive on ART','High risk population of HHCM with with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM with with HIV Positive on ART\n High risk population of HHCM with with HIV Positive on ART\n \n 2023-03-29 21:18:20 UTC\n \n 2023-03-29 21:19: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 1949\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:18:20',4,'2023-03-29 23:19:22',4,0,NULL,NULL,NULL,'360494e1-ccad-4e72-bf80-c564f2cfe18b'),(1950,'HHXM with HIV Positive on ART','High risk population of HHXM with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM with HIV Positive on ART\n High risk population of HHXM with HIV Positive on ART\n \n 2023-03-29 21:20:51 UTC\n \n 2023-03-29 21:25: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 1950\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:20:51',4,'2023-03-29 23:25:50',4,0,NULL,NULL,NULL,'ce4eaae7-7985-4e89-ab65-3b0c1686f80e'),(1951,'Miners with HIV Positive on ART','High risk population of Miners with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Miners with HIV Positive on ART\n High risk population of Miners with HIV Positive on ART\n \n 2023-03-29 21:27:27 UTC\n \n 2023-03-29 21:30: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 1951\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:27:27',4,'2023-03-29 23:30:27',4,0,NULL,NULL,NULL,'19d13a38-7625-4136-b870-a7facc92ecb3'),(1952,'New and Relapse with HIV Positive on ART','High risk population of New and Relapse with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse with HIV Positive on ART\n High risk population of New and Relapse with HIV Positive on ART\n \n 2023-03-29 21:33:41 UTC\n \n 2023-03-29 21:36: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 1952\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:33:41',4,'2023-03-29 23:36:00',4,0,NULL,NULL,NULL,'86db5b09-049a-4be4-a35f-f02f9de644f6'),(1953,'Public transport operators with HIV Positive on ART','High risk population of Public transport operators with HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public transport operators with HIV Positive on ART\n High risk population of Public transport operators with HIV Positive on ART\n \n 2023-03-29 21:37:07 UTC\n \n 2023-03-29 21:38: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 1953\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:37:07',4,'2023-03-29 23:38:05',4,0,NULL,NULL,NULL,'ebbb00b2-3779-47b8-8265-c8afea8a5ac1'),(1954,'Retreatment with HIV Positive on ART','High risk population of Retreatment Excl. Relapse HIV Positive on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment with HIV Positive on ART\n High risk population of Retreatment Excl. Relapse HIV Positive on ART\n \n 2023-03-29 21:39:16 UTC\n \n 2023-03-29 21:40: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 1954\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:39:16',4,'2023-03-29 23:40:08',4,0,NULL,NULL,NULL,'2ffdb12c-d02b-4e9a-a1dc-6e4974093b5a'),(1955,'Children < 15 with Positive HIV on CPT/Dapzone','Children < 15 with Positive HIV on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children < 15 with Positive HIV on CPT/Dapzone\n Children < 15 with Positive HIV on CPT/Dapzone\n \n 2023-03-29 21:44:42 UTC\n \n 2023-03-29 21:47: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 1955\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:44:42',4,'2023-03-29 23:47:53',4,0,NULL,NULL,NULL,'78313782-541c-4568-956c-9fb7bf92c08b'),(1956,'Correctional Staff and inmates with HIV Positive on CPT/Dapzone','High risk population of Correctional Staff and inmates with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Correctional Staff and inmates with HIV Positive on CPT/Dapzone\n High risk population of Correctional Staff and inmates with HIV Positive on CPT/Dapzone\n \n 2023-03-29 21:54:08 UTC\n \n 2023-03-29 21:56: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 1956\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:54:08',4,'2023-03-29 23:56:48',4,0,NULL,NULL,NULL,'46e76f2a-4fc0-40cf-be9d-61565edbe566'),(1957,'Ex Miner with HIV Positive on CPT/Dapzone','High risk population of Ex Miner with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex Miner with HIV Positive on CPT/Dapzone\n High risk population of Ex Miner with HIV Positive on CPT/Dapzone\n \n 2023-03-29 21:58:20 UTC\n \n 2023-03-29 21:59: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 1957\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-29 23:58:20',4,'2023-03-29 23:59:20',4,0,NULL,NULL,NULL,'348df991-95e1-4724-8df6-e4d905d67b11'),(1958,'Factory Workers with HIV Positive on CPT/Dapzone','High risk population of Factory Workers with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Workers with HIV Positive on CPT/Dapzone\n High risk population of Factory Workers with HIV Positive on CPT/Dapzone\n \n 2023-03-29 22:00:58 UTC\n \n 2023-03-29 22:02: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 1958\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 00:00:58',4,'2023-03-30 00:02:05',4,0,NULL,NULL,NULL,'5ce50877-ee92-48de-bfa7-a863b735975e'),(1959,'Health workers with HIV Positive on CPT/Dapzone','High risk population of Health workers with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health workers with HIV Positive on CPT/Dapzone\n High risk population of Health workers with HIV Positive on CPT/Dapzone\n \n 2023-03-29 22:03:33 UTC\n \n 2023-03-29 22:06: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 1959\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 00:03:33',4,'2023-03-30 00:06:16',4,0,NULL,NULL,NULL,'e47447de-6a64-422f-abe3-c281d2b4431c'),(1960,'HHCM with HIV Positive on CPT/Dapzone','High risk population of HHCM with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM with HIV Positive on CPT/Dapzone\n High risk population of HHCM with HIV Positive on CPT/Dapzone\n \n 2023-03-29 22:08:00 UTC\n \n 2023-03-29 22:09: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 1960\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 00:08:00',4,'2023-03-30 00:09:04',4,0,NULL,NULL,NULL,'02d9a185-dc0e-4852-8176-c4da69705d5d'),(1961,'HHXM with HIV Positive on CPT/Dapzone','High risk population of HHXM with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM with HIV Positive on CPT/Dapzone\n High risk population of HHXM with HIV Positive on CPT/Dapzone\n \n 2023-03-29 22:10:38 UTC\n \n 2023-03-29 22:11: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 1961\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 00:10:38',4,'2023-03-30 00:11:51',4,0,NULL,NULL,NULL,'c86cc664-d513-4afe-97b9-8163b4bb39d1'),(1962,'Miners with HIV Positive on CPT/Dapzone','High risk population Miners with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Miners with HIV Positive on CPT/Dapzone\n High risk population Miners with HIV Positive on CPT/Dapzone\n \n 2023-03-29 22:13:17 UTC\n \n 2023-03-29 22:15: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 1962\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 00:13:17',4,'2023-03-30 00:15:15',4,0,NULL,NULL,NULL,'7751e110-9e34-453e-bd9f-792272cbd895'),(1963,'New and Relapse with HIV Positive on CPT/Dapzone','High risk population of New and Relapse with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse with HIV Positive on CPT/Dapzone\n High risk population of New and Relapse with HIV Positive on CPT/Dapzone\n \n 2023-03-29 22:16:42 UTC\n \n 2023-03-29 22:18: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 1963\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 00:16:42',4,'2023-03-30 00:18:40',4,0,NULL,NULL,NULL,'2ebc8503-89e4-41f4-bdaf-e9e1d041a147'),(1964,'Public transport operators with HIV Positive on CPT/Dapzone','High risk population of Public transport operators with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public transport operators with HIV Positive on CPT/Dapzone\n High risk population of Public transport operators with HIV Positive on CPT/Dapzone\n \n 2023-03-30 08:39:11 UTC\n \n 2023-03-30 08:40: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 1964\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 10:39:11',4,'2023-03-30 10:40:29',4,0,NULL,NULL,NULL,'575068b5-f0ca-4d5b-8181-663b5feded65'),(1965,'Retreatment with HIV Positive on CPT/Dapzone','Retreatment Excl. Relapse with HIV Positive on CPT/Dapzone','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment with HIV Positive on CPT/Dapzone\n Retreatment Excl. Relapse with HIV Positive on CPT/Dapzone\n \n 2023-03-30 08:41:45 UTC\n \n 2023-03-30 08:48: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 1965\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 10:41:45',4,'2023-03-30 10:48:08',4,0,NULL,NULL,NULL,'22dbd0dd-a4ca-42a5-986e-6c0012eb55b1'),(1966,'HHXM with Documented HIV Status','High risk population of HHXM with Documented HIV Status','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM with Documented HIV Status\n High risk population of HHXM with Documented HIV Status\n \n 2023-03-30 09:03:54 UTC\n \n 2023-03-30 09:06: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 1966\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-03-30 11:03:54',4,'2023-03-30 11:06:14',4,0,NULL,NULL,NULL,'e5de47f6-aa7a-4b2d-bd72-83e5458977d6'),(1967,'TB Notification - Block 4','TB Notification - Block 4','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Notification - Block 4\n TB Notification - Block 4\n \n 2023-03-30 09:18:19 UTC\n \n 2023-03-30 20:54: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 1967\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-03-30 11:18:19',4,'2023-03-30 22:54:40',4,0,NULL,NULL,NULL,'0b9affca-ad93-42fb-bd49-57380f721a08'),(1968,'TBNotification - Block 4 Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TBNotification - Block 4 Data Set\n \n 2023-03-30 09:18:47 UTC\n \n 2023-03-30 20:50: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 1968\n \n \n DM_Sex\n \n \n \n \n \n \n \n \n ARTChild_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 ARTChild_M\n \n \n \n \n DM_Sex\n Males\n \n \n \n \n \n ARTCo&In_F\n \n \n \n \n \n \n \n \n \n ARTCo&In_M\n \n \n \n \n \n \n ARTFacW_F\n \n \n \n \n \n \n \n \n \n ARTFacW_M\n \n \n \n \n \n \n ARTHHCM_F\n \n \n \n \n \n \n \n \n \n ARTHHCM_M\n \n \n \n \n \n \n ARTHHXM_F\n \n \n \n \n \n \n \n \n \n ARTHHXM_M\n \n \n \n \n \n \n ARTHeaW_F\n \n \n \n \n \n \n \n \n \n ARTHeaW_M\n \n \n \n \n \n \n ARTMiner_F\n \n \n \n \n \n \n \n \n \n ARTMiner_M\n \n \n \n \n \n \n ARTNw&Rl_F\n \n \n \n \n \n \n \n \n \n ARTNw&Rl_M\n \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 ARTTrans_F\n \n \n \n \n \n \n \n \n \n ARTTrans_M\n \n \n \n \n \n \n ARTXMine_F\n \n \n \n \n \n \n \n \n \n ARTXMine_M\n \n \n \n \n \n \n DapChild_F\n \n \n \n \n \n \n \n \n \n DapChild_M\n \n \n \n \n \n \n DapCo&In_F\n \n \n \n \n \n \n \n \n \n DapCo&In_M\n \n \n \n \n \n \n DapFacW_F\n \n \n \n \n \n \n \n \n \n DapFacW_M\n \n \n \n \n \n \n DapHHCM_F\n \n \n \n \n \n \n \n \n \n DapHHCM_M\n \n \n \n \n \n \n DapHHXM_F\n \n \n \n \n \n \n \n \n \n DapHHXM_M\n \n \n \n \n \n \n DapHeaW_F\n \n \n \n \n \n \n \n \n \n DapHeaW_M\n \n \n \n \n \n \n DapMiner_F\n \n \n \n \n \n \n \n \n \n DapMiner_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 DapTrans_F\n \n \n \n \n \n \n \n \n \n DapTrans_M\n \n \n \n \n \n \n DapXMine_F\n \n \n \n \n \n \n \n \n \n DapXMine_M\n \n \n \n \n \n \n PosChild_F\n \n \n \n \n \n \n \n \n \n PosChild_M\n \n \n \n \n \n \n PosCo&In_F\n \n \n \n \n \n \n \n \n \n PosCo&In_M\n \n \n \n \n \n \n PosFacW_F\n \n \n \n \n \n \n \n \n \n PosFacW_M\n \n \n \n \n \n \n PosHHCM_F\n \n \n \n \n \n \n \n \n \n PosHHCM_M\n \n \n \n \n \n \n PosHHXM_F\n \n \n \n \n \n \n \n \n \n PosHHXM_M\n \n \n \n \n \n \n PosHeaW_F\n \n \n \n \n \n \n \n \n \n PosHeaW_M\n \n \n \n \n \n \n PosMiner_F\n \n \n \n \n \n \n \n \n \n PosMiner_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 PosTrans_F\n \n \n \n \n \n \n \n \n \n PosTrans_M\n \n \n \n \n \n \n PosXMine_F\n \n \n \n \n \n \n \n \n \n PosXMine_M\n \n \n \n \n \n \n StsChild_F\n \n \n \n \n \n \n \n \n \n StsChild_M\n \n \n \n \n \n \n StsCo&In_F\n \n \n \n \n \n \n \n \n \n StsCo&In_M\n \n \n \n \n \n \n StsFacW_F\n \n \n \n \n \n \n \n \n \n StsFacW_M\n \n \n \n \n \n \n StsHHCM_F\n \n \n \n \n \n \n \n \n \n StsHHCM_M\n \n \n \n \n \n \n StsHHXM_F\n \n \n \n \n \n \n \n \n \n StsHHXM_M\n \n \n \n \n \n \n StsHeaW_F\n \n \n \n \n \n \n \n \n \n StsHeaW_M\n \n \n \n \n \n \n StsMin_F\n \n \n \n \n \n \n \n \n \n StsMin_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 \n \n \n StsRetre_M\n \n \n \n \n \n \n StsTrans_F\n \n \n \n \n \n \n \n \n \n StsTrans_M\n \n \n \n \n \n \n StsXMin_F\n \n \n \n \n \n \n \n \n \n StsXMin_M\n \n \n \n \n \n \n','2023-03-30 11:18:47',4,'2023-03-30 22:50:08',4,0,NULL,NULL,NULL,'e08d273c-ba6d-4085-bf72-b7f6737396bf'),(1969,'TB_OUTCOMES','TB Outcomes','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB_OUTCOMES\n TB Outcomes\n \n 2023-03-30 13:48:45 UTC\n \n 2023-03-30 14:06: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 1969\n \n \n Competed\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-03-30 15:48:45',4,'2023-03-30 16:06:44',4,0,NULL,NULL,NULL,'2244b6f7-5dd0-4c8a-8a9e-67bac3fe7d9b'),(1970,'test','test','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n test\n test\n \n 2023-03-30 14:06:01 UTC\n \n \n','2023-03-30 16:06:01',4,NULL,NULL,0,NULL,NULL,NULL,'a572d104-f644-42bb-ae58-7c83ac0747ad'),(1971,'TB New and Relapse Completed','TB New and Relapse Completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Completed\n TB New and Relapse Completed\n \n 2023-03-30 14:58:43 UTC\n \n 2023-03-30 14: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 1971\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 -- TB History of previous treatment \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 (1034,1084) \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 and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 16:58:43',4,'2023-03-30 16:59:47',4,0,NULL,NULL,NULL,'1540870d-551a-4e11-baad-70ed9b13289a'),(1972,'TB New and Relapse Cured','TB New and Relapse Cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Cured\n TB New and Relapse Cured\n \n 2023-03-30 15:04:42 UTC\n \n 2023-03-30 15:06: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 1972\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 -- TB History of previous treatment(New AND 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 (1034,1084) \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-03-30 17:04:42',4,'2023-03-30 17:06:17',4,0,NULL,NULL,NULL,'22e1906b-16cd-4109-b529-a043e43ff3d4'),(1973,'TB New and Relapse Died','TB New and Relapse Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Died\n TB New and Relapse Died\n \n 2023-03-30 15:08:32 UTC\n \n 2023-03-30 15:09: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 1973\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 -- TB History of previous treatment(New AND 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 (1034,1084) \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-03-30 17:08:32',4,'2023-03-30 17:09:15',4,0,NULL,NULL,NULL,'19636929-afd0-4ba0-acfa-bbe325e1f002'),(1974,'TB New and Relapse Lost to Follow-up','TB New and Relapse 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 TB New and Relapse Lost to Follow-up\n TB New and Relapse Lost to Follow-up\n \n 2023-03-30 15:10:23 UTC\n \n 2023-03-30 15:10: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 1974\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 -- TB History of previous treatment(New AND 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 (1034,1084) \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-03-30 17:10:23',4,'2023-03-30 17:10:58',4,0,NULL,NULL,NULL,'87260731-779f-4244-9480-f75169dd2fbf'),(1975,'TB New and Relapse Failed (Susceptible)','TB New and Relapse Failed (Susceptible)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Failed (Susceptible)\n TB New and Relapse Failed (Susceptible)\n \n 2023-03-30 15:11:55 UTC\n \n 2023-03-30 15:31: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 1975\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 -- TB History of previous treatment(New AND 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 (1034,1084) \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-03-30 17:11:55',4,'2023-03-30 17:31:39',4,0,NULL,NULL,NULL,'53aec520-fab0-4871-b46f-209c32b921c1'),(1976,'TB New and Relapse Not Evaluated','TB New and Relapse Not Evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Not Evaluated\n TB New and Relapse Not Evaluated\n \n 2023-03-30 15:13:29 UTC\n \n 2023-03-30 16:05: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 1976\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 -- TB History of previous treatment(New AND 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 (1034,1084) \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,2242,3650,2302,3793,3794) \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 17:13:29',4,'2023-03-30 18:05:12',4,0,NULL,NULL,NULL,'0af163fd-0d3c-4b6a-a84e-1648cd9bb042'),(1977,'exMiner_cured','Ex miner cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n exMiner_cured\n Ex miner cured\n \n 2023-03-30 15:21:40 UTC\n \n 2023-03-30 15:47: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 1977\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 = 3668 \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 = 1068 \n and b.voided = 0 \n ) \n\n','2023-03-30 17:21:40',4,'2023-03-30 17:47:23',4,0,NULL,NULL,NULL,'4c2c88ec-ee4e-4bad-962d-229983982f12'),(1978,'exMiner_completed','Ex miner completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n exMiner_completed\n Ex miner completed\n \n 2023-03-30 15:24:54 UTC\n \n 2023-03-30 15:45: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 1978\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 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 = 3668 \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 = 2242 \n and b.voided = 0 \n ) \n\n','2023-03-30 17:24:54',4,'2023-03-30 17:45:56',4,0,NULL,NULL,NULL,'37afe774-0ef1-4152-8ab9-fe702f175f36'),(1979,'exMiner_died','Ex Miner died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n exMiner_died\n Ex Miner died\n \n 2023-03-30 15:28:17 UTC\n \n 2023-04-03 07:35: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 1979\n select distinct o.person_id \n \n \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 = 3668 \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 = 3650 and b.voided = 0 \n ) \n\n','2023-03-30 17:28:17',4,'2023-04-03 09:35:05',4,0,NULL,NULL,NULL,'d08b3fb0-d1c2-455d-89a6-f3c9a1469a3e'),(1980,'TB New and Relapse Completed Moved to second line treatment','TB New and Relapse Completed Moved to second line treatment','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Completed Moved to second line treatment\n TB New and Relapse Completed Moved to second line treatment\n \n 2023-03-30 15:33:00 UTC\n \n 2023-03-30 15:33: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 1980\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 -- TB History of previous treatment(New AND 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 (1034,1084) \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-03-30 17:33:00',4,'2023-03-30 17:33:47',4,0,NULL,NULL,NULL,'d2ff18e1-1cf3-4bff-9796-e35aaf019b40'),(1981,'exMiner_failedSusceptive','Ex miner failed suceptive','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n exMiner_failedSusceptive\n Ex miner failed suceptive\n \n 2023-03-30 15:40:13 UTC\n \n 2023-04-03 10:56: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 1981\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 = 3668 \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 = 3793 \n and b.voided = 0 \n ) \n\n','2023-03-30 17:40:13',4,'2023-04-03 12:56:48',4,0,NULL,NULL,NULL,'8c7c6720-c1aa-492a-be1b-47edc57cfd55'),(1982,'exMiner_lost','Ex miner lost','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n exMiner_lost\n Ex miner lost\n \n 2023-03-30 15:42:32 UTC\n \n 2023-03-30 15:49: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 1982\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 = 3668 \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 = 2302 \n and b.voided = 0 \n ) \n\n','2023-03-30 17:42:32',4,'2023-03-30 17:49:29',4,0,NULL,NULL,NULL,'cb57dd5b-22ae-42d9-a86a-6927e9aae9cb'),(1983,'TB Retreatment excluding Relapse and Completed','TB Retreatment excluding Relapse and Completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Retreatment excluding Relapse and Completed\n TB Retreatment excluding Relapse and Completed\n \n 2023-03-30 15:43:38 UTC\n \n 2023-03-30 15:44: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 1983\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 -- TB History of previous treatment(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 = 2242 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 17:43:38',4,'2023-03-30 17:44:32',4,0,NULL,NULL,NULL,'93eefc43-0eba-4a27-8d7e-72958dc0b2f1'),(1984,'exMiner_movedSecondLIne','Ex miner moved to second line','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n exMiner_movedSecondLIne\n Ex miner moved to second line\n \n 2023-03-30 15:44:13 UTC\n \n 2023-03-30 15:44: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 1984\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 = 3668 \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 = 3794 \n and b.voided = 0 \n ) \n\n','2023-03-30 17:44:13',4,'2023-03-30 17:44:34',4,0,NULL,NULL,NULL,'846e0252-747b-4457-b0f4-6f23ed244706'),(1985,'TB Retreatment excluding Relapse and Cured','TB Retreatment excluding Relapse and Cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Retreatment excluding Relapse and Cured\n TB Retreatment excluding Relapse and Cured\n \n 2023-03-30 15:45:00 UTC\n \n 2023-03-30 15:45: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 1985\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 -- TB History of previous treatment(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 = 1068 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 17:45:00',4,'2023-03-30 17:45:29',4,0,NULL,NULL,NULL,'1cd8596a-21ba-4a7b-b3c6-c82fb756bf8f'),(1986,'TB Retreatment excluding Relapse and Died','TB Retreatment excluding Relapse and Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Retreatment excluding Relapse and Died\n TB Retreatment excluding Relapse and Died\n \n 2023-03-30 15:45:57 UTC\n \n 2023-03-30 15:46: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 1986\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 -- TB History of previous treatment(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 = 3650 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 17:45:57',4,'2023-03-30 17:46:22',4,0,NULL,NULL,NULL,'50001a13-545a-4de2-9617-86c8b262eb9d'),(1987,'TB Retreatment excluding Relapse and Lost to Follow up','TB Retreatment excluding Relapse and 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 TB Retreatment excluding Relapse and Lost to Follow up\n TB Retreatment excluding Relapse and Lost to Follow up\n \n 2023-03-30 15:47:18 UTC\n \n 2023-03-30 15:47: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 1987\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 -- TB History of previous treatment(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 = 2302 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 17:47:18',4,'2023-03-30 17:47:57',4,0,NULL,NULL,NULL,'46fbbe80-0f0e-4cf5-8f4d-04444b70d3bc'),(1988,'TB Retreatment excluding Relapse and Failed (Susceptible)','TB Retreatment excluding Relapse and Failed (Susceptible)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Retreatment excluding Relapse and Failed (Susceptible)\n TB Retreatment excluding Relapse and Failed (Susceptible)\n \n 2023-03-30 15:49:14 UTC\n \n 2023-03-30 15:49: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 1988\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 -- TB History of previous treatment(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 = 3793 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 17:49:14',4,'2023-03-30 17:49:46',4,0,NULL,NULL,NULL,'0b97c9a2-f4f0-460c-9a6a-943f0d0b9bac'),(1989,'TB Retreatment excluding Relapse and Not Evaluated','TB Retreatment excluding Relapse and Not Evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Retreatment excluding Relapse and Not Evaluated\n TB Retreatment excluding Relapse and Not Evaluated\n \n 2023-03-30 15:51:27 UTC\n \n 2023-03-30 16: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 1989\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 -- TB History of previous treatment(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 not in ( \n select o.person_id \n from obs o \n where o.concept_id = 3792 and o.value_coded in (1068,2242,3650,2302,3793,3794) \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 17:51:27',4,'2023-03-30 18:03:56',4,0,NULL,NULL,NULL,'36e8a6f3-f70c-4d36-ab76-87fba12b426b'),(1990,'exMiner_notEvaluated','Ex miner not evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n exMiner_notEvaluated\n Ex miner not evaluated\n \n 2023-03-30 15:53:42 UTC\n \n 2023-03-30 16:13: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 1990\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 = 3668 \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-03-30 17:53:42',4,'2023-03-30 18:13:01',4,0,NULL,NULL,NULL,'af666d60-a3d1-4f0f-8ac2-1ea8fddbf8cd'),(1991,'FactoryWorker_notEvaluated','Factory worker not evaluated ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n FactoryWorker_notEvaluated\n Factory worker not evaluated \n \n 2023-03-30 16:17:17 UTC\n \n 2023-03-30 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 1991\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 = 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 (2302,1068,2242,3650,3793,3794) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:17:17',4,'2023-03-30 18:18:05',4,0,NULL,NULL,NULL,'83566c8a-550c-447e-9745-0df04c89de07'),(1992,'FactoryWorker_curred','Factory worker curred','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n FactoryWorker_curred\n Factory worker curred\n \n 2023-03-30 16:18:46 UTC\n \n 2023-03-30 16: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 1992\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 (1068) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:18:46',4,'2023-03-30 18:19:13',4,0,NULL,NULL,NULL,'40dd9f46-8d30-4426-bffd-0eb772046374'),(1993,'All TB HIV Pos and Completed ','All TB HIV Pos and Completed ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Pos and Completed \n All TB HIV Pos and Completed \n \n 2023-03-30 16:19:51 UTC\n \n 2023-03-30 16:20: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 1993\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 -- All HIV Positives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4323,4664) \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-03-30 18:19:51',4,'2023-03-30 18:20:08',4,0,NULL,NULL,NULL,'6b7c8fdf-00e6-4f52-b0fe-fab2cd9cc15e'),(1994,'FactoryWorker_completed','Factory worker copleted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n FactoryWorker_completed\n Factory worker copleted\n \n 2023-03-30 16:19:51 UTC\n \n 2023-03-30 16:20: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 1994\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 = 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 (2242) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:19:51',4,'2023-03-30 18:20:13',4,0,NULL,NULL,NULL,'4fb972d7-5378-4413-8faf-e9dfc9454cd6'),(1995,'All TB HIV Pos and Cured','All TB HIV Pos and Cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Pos and Cured\n All TB HIV Pos and Cured\n \n 2023-03-30 16:20:26 UTC\n \n 2023-03-30 16:20: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 1995\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 -- All HIV Positives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4323,4664) \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-03-30 18:20:26',4,'2023-03-30 18:20:55',4,0,NULL,NULL,NULL,'5bd61f52-4224-4de9-82cd-2c6334f665b1'),(1996,'FactoryWorker_died','Factory worker died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n FactoryWorker_died\n Factory worker died\n \n 2023-03-30 16:21:09 UTC\n \n 2023-03-30 16:21: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 1996\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 = 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 (3650) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:21:09',4,'2023-03-30 18:21:24',4,0,NULL,NULL,NULL,'f4cf99eb-4bb4-45c0-a403-086fd4b51c44'),(1997,'All TB HIV Pos and Died','All TB HIV Pos and Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Pos and Died\n All TB HIV Pos and Died\n \n 2023-03-30 16:21:20 UTC\n \n 2023-03-30 16:21: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 1997\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 -- All HIV Positives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4323,4664) \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-03-30 18:21:20',4,'2023-03-30 18:21:50',4,0,NULL,NULL,NULL,'b41362c1-57e7-48a0-99ed-a6241cd9fb3d'),(1998,'FactoryWorker_lost','Factort worker 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 FactoryWorker_lost\n Factort worker lost to follow up\n \n 2023-03-30 16:22:18 UTC\n \n 2023-03-30 16:22: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 1998\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 = 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 (2302) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:22:18',4,'2023-03-30 18:22:39',4,0,NULL,NULL,NULL,'f915f74e-1e06-4639-9070-6d1fa301b432'),(1999,'All TB HIV Pos and Lost to Follow up','All TB HIV Pos and 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 All TB HIV Pos and Lost to Follow up\n All TB HIV Pos and Lost to Follow up\n \n 2023-03-30 16:22:31 UTC\n \n 2023-03-30 16:22: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 1999\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 -- All HIV Positives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4323,4664) \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-03-30 18:22:31',4,'2023-03-30 18:22:58',4,0,NULL,NULL,NULL,'16efd94d-da75-4a5c-8ca9-6364f2fc8396'),(2000,'All TB HIV Pos and Failed (Susceptible)','All TB HIV Pos and Failed (Susceptible)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Pos and Failed (Susceptible)\n All TB HIV Pos and Failed (Susceptible)\n \n 2023-03-30 16:23:33 UTC\n \n 2023-03-30 16:24: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 2000\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 -- All HIV Positives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4323,4664) \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-03-30 18:23:33',4,'2023-03-30 18:24:00',4,0,NULL,NULL,NULL,'4dc42500-c285-4548-92ff-842d1b357342'),(2001,'prison_worker_lost','Prison worker lost','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n prison_worker_lost\n Prison worker lost\n \n 2023-03-30 16:24:03 UTC\n \n 2023-03-30 16:24: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 2001\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 = 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 (2302) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:24:03',4,'2023-03-30 18:24:36',4,0,NULL,NULL,NULL,'624478ae-cc98-4b93-b138-4e619755b41a'),(2002,'All TB HIV Pos and Not Evaluated','All TB HIV Pos and Not Evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Pos and Not Evaluated\n All TB HIV Pos and Not Evaluated\n \n 2023-03-30 16:24:48 UTC\n \n 2023-03-30 16:26: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 2002\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 -- All HIV Positives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4323,4664) \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,2242,3650,2302,3793,3794) \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 18:24:48',4,'2023-03-30 18:26:26',4,0,NULL,NULL,NULL,'4fe00951-413a-468e-ac7e-016dcf41bed6'),(2003,'FactoryWorker_moved','Facotory worker moved to second line','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n FactoryWorker_moved\n Facotory worker moved to second line\n \n 2023-03-30 16:26:31 UTC\n \n 2023-03-30 16:34: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 2003\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 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-03-30 18:26:31',4,'2023-03-30 18:34:39',4,0,NULL,NULL,NULL,'1a7a972b-4113-414d-8810-46c8df8137e7'),(2004,'All TB HIV Pos and Moved to Secondline','All TB HIV Pos and Moved to Secondline','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Pos and Moved to Secondline\n All TB HIV Pos and Moved to Secondline\n \n 2023-03-30 16:27:16 UTC\n \n 2023-03-30 16:27: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 2004\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 -- All HIV Positives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4323,4664) \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-03-30 18:27:16',4,'2023-03-30 18:27:43',4,0,NULL,NULL,NULL,'57ddf49d-b53d-48ce-a67d-3ce6398f3e2c'),(2005,'All TB HIV Neg and Completed','All TB HIV Neg and Completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Neg and Completed\n All TB HIV Neg and Completed\n \n 2023-03-30 16:29:02 UTC\n \n 2023-03-30 16:30: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 2005\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 -- All HIV Negatives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4324,4665) \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-03-30 18:29:02',4,'2023-03-30 18:30:27',4,0,NULL,NULL,NULL,'63a92814-2f34-4018-b7d0-47659892369d'),(2006,'All TB HIV Neg and Cured','All TB HIV Neg and Cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Neg and Cured\n All TB HIV Neg and Cured\n \n 2023-03-30 16:30:51 UTC\n \n 2023-03-30 16:31: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 2006\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 -- All HIV Negatives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4324,4665) \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-03-30 18:30:51',4,'2023-03-30 18:31:17',4,0,NULL,NULL,NULL,'8e552272-4654-43bb-b1af-20affab2de14'),(2007,'All TB HIV Neg and Died','All TB HIV Neg and Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Neg and Died\n All TB HIV Neg and Died\n \n 2023-03-30 16:31:44 UTC\n \n 2023-03-30 16:32: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 2007\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 -- All HIV Negatives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4324,4665) \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-03-30 18:31:44',4,'2023-03-30 18:32:11',4,0,NULL,NULL,NULL,'3463adc8-19aa-4cc0-9daf-32ea09e0c1f0'),(2008,'All TB HIV Neg and Lost to Follow up','All TB HIV Neg and 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 All TB HIV Neg and Lost to Follow up\n All TB HIV Neg and Lost to Follow up\n \n 2023-03-30 16:32:59 UTC\n \n 2023-03-30 16: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 2008\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 -- All HIV Negatives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4324,4665) \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-03-30 18:32:59',4,'2023-03-30 18:33:27',4,0,NULL,NULL,NULL,'06a5ff53-1949-444e-80b5-f4c99b38d5b1'),(2009,'All TB HIV Neg and Failed (Susceptible)','All TB HIV Neg and Failed (Susceptible)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Neg and Failed (Susceptible)\n All TB HIV Neg and Failed (Susceptible)\n \n 2023-03-30 16:34:17 UTC\n \n 2023-03-30 16:35: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 2009\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 -- All HIV Negatives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4324,4665) \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-03-30 18:34:17',4,'2023-03-30 18:35:01',4,0,NULL,NULL,NULL,'2ac7e18e-061b-4b34-bb63-63a2ec622a2b'),(2010,'All TB HIV Neg and Not Evaluated','All TB HIV Neg and Not Evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Neg and Not Evaluated\n All TB HIV Neg and Not Evaluated\n \n 2023-03-30 16:35:36 UTC\n \n 2023-03-30 16:37: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 2010\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 -- All HIV Negatives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4324,4665) \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,2242,3650,2302,3793,3794) \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 18:35:36',4,'2023-03-30 18:37:02',4,0,NULL,NULL,NULL,'c78c5a10-a320-43ce-b943-f9286e22ad1e'),(2011,'prison_worker_moved','Prison worker moved to second line','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n prison_worker_moved\n Prison worker moved to second line\n \n 2023-03-30 16:35:49 UTC\n \n 2023-03-30 16:36: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 2011\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 = 3779 \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-03-30 18:35:49',4,'2023-03-30 18:36:29',4,0,NULL,NULL,NULL,'76d5be40-a7e3-4f4f-968a-0346d0bd6513'),(2012,'prison_worker_died','Prison worker died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n prison_worker_died\n Prison worker died\n \n 2023-03-30 16:37:07 UTC\n \n 2023-03-30 16:37: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 2012\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 = 3776 \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-03-30 18:37:07',4,'2023-03-30 18:37:38',4,0,NULL,NULL,NULL,'c9a54e7c-34d1-4a1b-9214-0b9fa6eb6976'),(2013,'All TB HIV Neg and Moved to Secondline Treatment','All TB HIV Neg and 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 All TB HIV Neg and Moved to Secondline Treatment\n All TB HIV Neg and Moved to Secondline Treatment\n \n 2023-03-30 16:37:41 UTC\n \n 2023-03-30 16:38: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 2013\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 -- All HIV Negatives \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 4666 and o.value_coded in (4324,4665) \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-03-30 18:37:41',4,'2023-03-30 18:38:53',4,0,NULL,NULL,NULL,'2de9ce1c-6a79-43fe-ab19-1b9c9d2865d4'),(2014,'prison_worker_completed','Prison worker completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n prison_worker_completed\n Prison worker completed\n \n 2023-03-30 16:38:29 UTC\n \n 2023-03-30 16:38: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 2014\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 = 3776 \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-03-30 18:38:29',4,'2023-03-30 18:38:53',4,0,NULL,NULL,NULL,'9e174142-2794-43fc-95dd-9f3f92e4b379'),(2015,'prison_worker_curred','Prion worker curred','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n prison_worker_curred\n Prion worker curred\n \n 2023-03-30 16:40:22 UTC\n \n 2023-03-30 16: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 2015\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 = 3776 \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-03-30 18:40:22',4,'2023-03-30 18:43:23',4,0,NULL,NULL,NULL,'91f85b53-7dca-4730-a391-5198293d1cf9'),(2016,'All Childred and Completed','All Childred and Completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All Childred and Completed\n All Childred and Completed\n \n 2023-03-30 16:43:19 UTC\n \n 2023-03-30 16:46: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 2016\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 -- All Children \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 15 \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-03-30 18:43:19',4,'2023-03-30 18:46:26',4,0,NULL,NULL,NULL,'f300ef4e-70b5-4c81-b993-7d45d23f299e'),(2017,'prison_worker_notEvaluated','Prison worker not evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n prison_worker_notEvaluated\n Prison worker not evaluated\n \n 2023-03-30 16:46:21 UTC\n \n 2023-03-30 16:46: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 2017\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 = 3776 \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-03-30 18:46:21',4,'2023-03-30 18:46:41',4,0,NULL,NULL,NULL,'1c0c7eab-e438-4787-982a-bfb448fe7455'),(2018,'All Childred and Cured','All Childred and Cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All Childred and Cured\n All Childred and Cured\n \n 2023-03-30 16:46:51 UTC\n \n 2023-03-30 16:47: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 2018\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 -- All Children \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 15 \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-03-30 18:46:51',4,'2023-03-30 18:47:08',4,0,NULL,NULL,NULL,'1f8f36b9-85d6-4e32-b078-6c7e098974b1'),(2019,'All Childred and Died','All Childred and Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All Childred and Died\n All Childred and Died\n \n 2023-03-30 16:47:31 UTC\n \n 2023-03-30 16:48: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 2019\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 -- All Children \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 15 \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-03-30 18:47:31',4,'2023-03-30 18:48:00',4,0,NULL,NULL,NULL,'dd4822a7-86eb-4579-acda-bf0ff242eef5'),(2020,'health_worker_notEvaluated','Health worker not evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n health_worker_notEvaluated\n Health worker not evaluated\n \n 2023-03-30 16:47:35 UTC\n \n 2023-03-30 16:48: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 2020\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 = 3667 \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-03-30 18:47:35',4,'2023-03-30 18:48:03',4,0,NULL,NULL,NULL,'5d8bdedf-fc1e-46f8-b417-908519f3e645'),(2021,'All Childred and Lost to Follow up','All Childred and 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 All Childred and Lost to Follow up\n All Childred and Lost to Follow up\n \n 2023-03-30 16:48:38 UTC\n \n 2023-03-30 16:49: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 2021\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 -- All Children \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 15 \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-03-30 18:48:38',4,'2023-03-30 18:49:04',4,0,NULL,NULL,NULL,'2665ef1b-edbd-4c9d-b9f6-3d2d2cc3b0ad'),(2022,'health_worker_curred','Health worker curred','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n health_worker_curred\n Health worker curred\n \n 2023-03-30 16:48:53 UTC\n \n 2023-03-30 16:49: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 2022\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 = 3667 \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-03-30 18:48:53',4,'2023-03-30 18:49:19',4,0,NULL,NULL,NULL,'63064b04-2cce-4944-b53d-ddb2cdce8a2d'),(2023,'All Childred and Failed (Susceptible)','All Childred and Failed (Susceptible)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All Childred and Failed (Susceptible)\n All Childred and Failed (Susceptible)\n \n 2023-03-30 16:49:34 UTC\n \n 2023-03-30 16:50: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 2023\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 -- All Children \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 15 \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-03-30 18:49:34',4,'2023-03-30 18:50:01',4,0,NULL,NULL,NULL,'1b710ad4-75b5-4b64-b916-1806dca0013d'),(2024,'health_worker_completed','Health worker completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n health_worker_completed\n Health worker completed\n \n 2023-03-30 16:49:56 UTC\n \n 2023-04-03 20:37: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 2024\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 = 3667 \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-03-30 18:49:56',4,'2023-04-03 22:37:45',4,0,NULL,NULL,NULL,'6555808c-1103-4a6d-b13f-fd0fad7ff09f'),(2025,'All Childred and Not evaluated','All Childred and Not evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All Childred and Not evaluated\n All Childred and Not evaluated\n \n 2023-03-30 16:50:30 UTC\n \n 2023-03-30 16:51: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 2025\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 -- All Children \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 15 \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,2242,3650,2302,3794,3793) \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 18:50:30',4,'2023-03-30 18:51:54',4,0,NULL,NULL,NULL,'1b9b16cf-f254-43b5-b952-4d54f431ae49'),(2026,'health_worker_died','Healh worker died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n health_worker_died\n Healh worker died\n \n 2023-03-30 16:50:46 UTC\n \n 2023-03-30 16:51: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 2026\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 = 3667 \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-03-30 18:50:46',4,'2023-03-30 18:51:00',4,0,NULL,NULL,NULL,'e9c9f85f-123c-4b2f-9951-7b8c2be340af'),(2027,'health_worker_lost','Health worker lost','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n health_worker_lost\n Health worker lost\n \n 2023-03-30 16:51:39 UTC\n \n 2023-03-30 16:51: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 2027\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 = 3667 \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-03-30 18:51:39',4,'2023-03-30 18:51:55',4,0,NULL,NULL,NULL,'8b70ced1-8219-4206-b7ec-10c0242808c4'),(2028,'All Childred and Moved to Secondline Treatment','All Childred and 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 All Childred and Moved to Secondline Treatment\n All Childred and Moved to Secondline Treatment\n \n 2023-03-30 16:52:27 UTC\n \n 2023-03-30 16:53: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 2028\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 -- All Children \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 15 \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-03-30 18:52:27',4,'2023-03-30 18:53:11',4,0,NULL,NULL,NULL,'143c95e1-ae28-460c-92c2-3807e30dc704'),(2029,'health_worker_moved','Health worker moved to second line','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n health_worker_moved\n Health worker moved to second line\n \n 2023-03-30 16:52:49 UTC\n \n 2023-03-30 16:55: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 2029\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 = 3667 \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-03-30 18:52:49',4,'2023-03-30 18:55:13',4,0,NULL,NULL,NULL,'3a04d202-b320-463e-a233-40887022bfea'),(2030,'All TB Adolescent (10-19 yrs) and Completed ','All TB Adolescent (10-19 yrs) and Completed ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','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-03-30 16:55:50 UTC\n \n 2023-03-30 16: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 2030\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 -- All Adolescent (10-19 yrs) \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 20 \n and floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) > 9 \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-03-30 18:55:50',4,'2023-03-30 18:56:27',4,0,NULL,NULL,NULL,'788061f8-b372-4d67-b493-c20b96b948bf'),(2031,'public_transport_Moved','Public Transport move to second line','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n public_transport_Moved\n Public Transport move to second line\n \n 2023-03-30 16:55:50 UTC\n \n 2023-03-30 16:56: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 2031\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 = 4654 \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-03-30 18:55:50',4,'2023-03-30 18:56:22',4,0,NULL,NULL,NULL,'c2e7a54e-80e6-4535-a09f-32d93e8ce902'),(2032,'All TB Adolescent (10-19 yrs) and cured','All TB Adolescent (10-19 yrs) and cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','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-03-30 16:56:54 UTC\n \n 2023-03-30 16:57: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 2032\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 -- All Adolescent (10-19 yrs) \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 20 \n and floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) > 9 \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-03-30 18:56:54',4,'2023-03-30 18:57:31',4,0,NULL,NULL,NULL,'e620cd1b-bbe2-4c3d-93bb-fcbdc8b34d84'),(2033,'public_transport_lost','Public transport Lost','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n public_transport_lost\n Public transport Lost\n \n 2023-03-30 16:57:13 UTC\n \n 2023-03-30 16:57: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 2033\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 = 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 (2302) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:57:13',4,'2023-03-30 18:57:37',4,0,NULL,NULL,NULL,'0cc2e2d8-4cab-45c7-9b04-67c8bfd1bbfa'),(2034,'All TB Adolescent (10-19 yrs) and Died','All TB Adolescent (10-19 yrs) and Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','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-03-30 16:57:52 UTC\n \n 2023-03-30 16:58: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 2034\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 -- All Adolescent (10-19 yrs) \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 20 \n and floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) > 9 \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-03-30 18:57:52',4,'2023-03-30 18:58:21',4,0,NULL,NULL,NULL,'53ef1628-fe11-4b21-bab5-897e27196e04'),(2035,'public_transport_died','Public transport died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n public_transport_died\n Public transport died\n \n 2023-03-30 16:58:17 UTC\n \n 2023-03-30 16:58: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 2035\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 = 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 (3650) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:58:17',4,'2023-03-30 18:58:34',4,0,NULL,NULL,NULL,'bbc25dd6-f8ff-4c55-84e8-efd76d0ac281'),(2036,'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.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','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-03-30 16:58:49 UTC\n \n 2023-03-30 16: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 2036\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 -- All Adolescent (10-19 yrs) \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 20 \n and floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) > 9 \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-03-30 18:58:49',4,'2023-03-30 18:59:12',4,0,NULL,NULL,NULL,'509944d6-5988-405c-8aee-8a9329e1e141'),(2037,'public_transport_completed','Public transport completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n public_transport_completed\n Public transport completed\n \n 2023-03-30 16:59:27 UTC\n \n 2023-03-30 17:00: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 2037\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 (2242) \n and b.voided = 0 \n ) \n\n','2023-03-30 18:59:27',4,'2023-03-30 19:00:28',4,0,NULL,NULL,NULL,'d9a7884a-eabd-43cc-9757-64ae74a3cb9c'),(2038,'All TB Adolescent (10-19 yrs) and Failed (Susceptible)','All TB Adolescent (10-19 yrs) and Failed (Susceptible)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB Adolescent (10-19 yrs) and Failed (Susceptible)\n All TB Adolescent (10-19 yrs) and Failed (Susceptible)\n \n 2023-03-30 16:59:52 UTC\n \n 2023-03-30 17:00: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 2038\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 -- All Adolescent (10-19 yrs) \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 20 \n and floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) > 9 \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-03-30 18:59:52',4,'2023-03-30 19:00:27',4,0,NULL,NULL,NULL,'dd3ac915-529a-44c4-b086-fe9e21bc7553'),(2039,'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.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','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-03-30 17:01:19 UTC\n \n 2023-03-30 17:01: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 2039\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 -- All Adolescent (10-19 yrs) \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 20 \n and floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) > 9 \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-03-30 19:01:19',4,'2023-03-30 19:01:41',4,0,NULL,NULL,NULL,'216e1e3c-eed7-4802-96bb-fe3256161a08'),(2040,'public_transport_curred','Public transport curred','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n public_transport_curred\n Public transport curred\n \n 2023-03-30 17:01:20 UTC\n \n 2023-03-30 17:01: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 2040\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 = 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 (1068) \n and b.voided = 0 \n ) \n\n','2023-03-30 19:01:20',4,'2023-03-30 19:01:41',4,0,NULL,NULL,NULL,'faf660cd-1ef3-48a9-86d5-805f14b23465'),(2041,'All TB Adolescent (10-19 yrs) and Not Evaluated','All TB Adolescent (10-19 yrs) and Not Evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','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-03-30 17:02:10 UTC\n \n 2023-03-30 17:03: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 2041\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 -- All Adolescent (10-19 yrs) \n and o.person_id in ( \n select o.person_id \n from obs o \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 where floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) < 20 \n and floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) > 9 \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,2242,3650,2302,3794,3793) \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 19:02:10',4,'2023-03-30 19:03:44',4,0,NULL,NULL,NULL,'8fcd3cec-a879-4240-888f-42575228b47d'),(2042,'public_transport_notEvaluated','Public transport note evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n public_transport_notEvaluated\n Public transport note evaluated\n \n 2023-03-30 17:02:53 UTC\n \n 2023-03-30 17:03: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 2042\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 (2302,1068,2242,3650,3793,3794) \n and b.voided = 0 \n ) \n\n','2023-03-30 19:02:53',4,'2023-03-30 19:03:45',4,0,NULL,NULL,NULL,'7037beac-7eba-4b7f-a3b7-6636d1d435bd'),(2043,'TB Females and Completed','TB Females and Completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Females and Completed\n TB Females and Completed\n \n 2023-03-30 17:07:55 UTC\n \n 2023-03-30 17:08: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 2043\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 -- Female \n and o.person_id in ( \n select o.person_id \n from obs o \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 where person.gender = 'F' \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-03-30 19:07:55',4,'2023-03-30 19:08:14',4,0,NULL,NULL,NULL,'82abec75-7c2a-4607-b3b1-b3ef5c6c4361'),(2044,'TB Females and Cured','TB Females and Cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Females and Cured\n TB Females and Cured\n \n 2023-03-30 17:08:50 UTC\n \n 2023-03-30 17:09: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 2044\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 -- Female \n and o.person_id in ( \n select o.person_id \n from obs o \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 where person.gender = 'F' \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-03-30 19:08:50',4,'2023-03-30 19:09:12',4,0,NULL,NULL,NULL,'f746ec4b-a949-4b53-86c8-4e1a71843d72'),(2045,'HHCM_notEvaluated','HHCM Note Evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM_notEvaluated\n HHCM Note Evaluated\n \n 2023-03-30 17:09:07 UTC\n \n 2023-03-30 17:09: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 2045\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 = 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 (2302,1068,2242,3650,3793,3794) \n and b.voided = 0 \n ) \n\n','2023-03-30 19:09:07',4,'2023-03-30 19:09:44',4,0,NULL,NULL,NULL,'d8caa7dd-326a-46f7-97ee-f7205689bfda'),(2046,'HHCM_curred','HHCM Curred','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM_curred\n HHCM Curred\n \n 2023-03-30 17:10:16 UTC\n \n 2023-03-30 17:10: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 2046\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 = 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 (1068) \n and b.voided = 0 \n ) \n\n','2023-03-30 19:10:16',4,'2023-03-30 19:10:39',4,0,NULL,NULL,NULL,'ea1cc81f-9ccc-4401-80e9-57a84da98f58'),(2047,'TB Females and Died','TB Females and Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Females and Died\n TB Females and Died\n \n 2023-03-30 17:11:17 UTC\n \n 2023-03-30 17:11: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 2047\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 -- Female \n and o.person_id in ( \n select o.person_id \n from obs o \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 where person.gender = 'F' \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-03-30 19:11:17',4,'2023-03-30 19:11:45',4,0,NULL,NULL,NULL,'f55690e5-8b8d-43ce-b797-f0f8707d1222'),(2048,'HHCM_completed','HHCM Completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM_completed\n HHCM Completed\n \n 2023-03-30 17:12:02 UTC\n \n 2023-03-30 17:12: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 2048\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 = 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 (2242) \n and b.voided = 0 \n ) \n\n','2023-03-30 19:12:02',4,'2023-03-30 19:12:21',4,0,NULL,NULL,NULL,'7dbf3689-913d-4883-ae4b-5be2aee4ba37'),(2049,'TB Females and Lost to Follow up','TB Females and 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 TB Females and Lost to Follow up\n TB Females and Lost to Follow up\n \n 2023-03-30 17:12:17 UTC\n \n 2023-03-30 17:13: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 2049\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 -- Female \n and o.person_id in ( \n select o.person_id \n from obs o \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 where person.gender = 'F' \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-03-30 19:12:17',4,'2023-03-30 19:13:14',4,0,NULL,NULL,NULL,'71a12f10-af92-4eba-88f2-176a2cb3ae14'),(2050,'HHCM_died','HHCM Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM_died\n HHCM Died\n \n 2023-03-30 17:12:43 UTC\n \n 2023-03-30 17:13: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 2050\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 = 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 (3650) \n and b.voided = 0 \n ) \n\n','2023-03-30 19:12:43',4,'2023-03-30 19:13:08',4,0,NULL,NULL,NULL,'87c6de2e-d87a-430b-a15e-d5de45e36410'),(2051,'HHCM_lost','HHCM Lost','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM_lost\n HHCM Lost\n \n 2023-03-30 17:13:35 UTC\n \n 2023-03-30 17:14: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 2051\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 = 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 (2302) \n and b.voided = 0 \n ) \n\n','2023-03-30 19:13:35',4,'2023-03-30 19:14:00',4,0,NULL,NULL,NULL,'543f25df-61ec-4cec-847f-816fec3268ec'),(2052,'TB Females and Failed (Susceptible)','TB Females and Failed (Susceptible)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Females and Failed (Susceptible)\n TB Females and Failed (Susceptible)\n \n 2023-03-30 17:14:08 UTC\n \n 2023-03-30 17:14: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 2052\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 -- Female \n and o.person_id in ( \n select o.person_id \n from obs o \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 where person.gender = 'F' \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-03-30 19:14:08',4,'2023-03-30 19:14:24',4,0,NULL,NULL,NULL,'d1085653-8aca-440b-ae5c-d899217ef3b5'),(2053,'HHCM_moved','HHCM Moved','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM_moved\n HHCM Moved\n \n 2023-03-30 17:14:34 UTC\n \n 2023-03-30 17:14:52 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 2053\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 = 3777 \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-03-30 19:14:34',4,'2023-03-30 19:14:52',4,0,NULL,NULL,NULL,'43bc5260-c525-4968-a427-01e7febdfef1'); +INSERT INTO `serialized_object` VALUES (2054,'TB Females and Moved to SecondLine','TB Females and Moved to SecondLine','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Females and Moved to SecondLine\n TB Females and Moved to SecondLine\n \n 2023-03-30 17:14:53 UTC\n \n 2023-03-30 17:15: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 2054\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 -- Female \n and o.person_id in ( \n select o.person_id \n from obs o \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 where person.gender = 'F' \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-03-30 19:14:53',4,'2023-03-30 19:15:09',4,0,NULL,NULL,NULL,'56836385-8ef8-49a4-bdc7-e7ac24baadb9'),(2055,'TB Females and Not Evaluated','TB Females and Not Evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Females and Not Evaluated\n TB Females and Not Evaluated\n \n 2023-03-30 17:15:40 UTC\n \n 2023-03-30 17:16: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 2055\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 -- Female \n and o.person_id in ( \n select o.person_id \n from obs o \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 where person.gender = 'F' \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,2242,3650,2302,3793,3794) \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-03-30 19:15:40',4,'2023-03-30 19:16:46',4,0,NULL,NULL,NULL,'d1ccfc19-7910-4d71-8ba4-1b31cfbc17b7'),(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-12-20 07:10: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 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 16:20:07',4,'2023-12-20 09:10:01',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-12-20 07:15: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 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 17:45:38',4,'2023-12-20 09:15:07',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'); +INSERT INTO `serialized_object` VALUES (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'),(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 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:51:33 UTC\n \n 2023-12-20 07: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 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-12-20 09:08:34',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'); +INSERT INTO `serialized_object` VALUES (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'),(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'); +INSERT INTO `serialized_object` VALUES (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'),(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 2024-04-25 10:31: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 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 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 in (10,19) \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 18:10:58',4,'2024-04-25 16:01:31',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 2024-02-06 12:38: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 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 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 18:11:53',4,'2024-02-06 18:08:12',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 2024-02-06 10:21: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 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(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.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 18:12:21',4,'2024-02-06 15:51:22',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 2024-02-06 12: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 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 in (4189,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 18:21:29',4,'2024-02-06 18:10:40',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 2024-05-23 14:45: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 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 I_Register\n \n \n \n \n \n \n \n \n \n Intakes\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 18:36:21',4,'2024-05-23 20:15:38',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 2024-02-06 09:57: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 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(:startDate as date) \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(:startDate as date) \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 14:09:02',4,'2024-02-06 15:27:28',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'),(2600,'Contacts of TB Patients','Contacts of TB Patients','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB Patients\n Contacts of TB Patients\n \n 2024-02-27 09:43:12 UTC\n \n 2024-02-27 10:34: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 2600\n select contact.person_id \n from \n (select B.person_id, B.obs_datetime \n from obs B \n inner join \n (select person_id, max(obs_datetime) as latest_consultation \n from obs where concept_id = 5926 \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.latest_consultation = B.obs_datetime \n where concept_id = 5962 and value_coded = 2146 \n and A.latest_consultation = B.obs_datetime \n and voided = 0 \n group by B.person_id \n ) as contact\n','2024-02-27 15:13:12',4,'2024-02-27 16:04:55',4,0,NULL,NULL,NULL,'f74fefb2-b6d4-4c26-b214-fdb965aeb103'),(2601,'Contacts of TB Patients screened for TB','Contacts of TB Patients screened for TB','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB Patients screened for TB\n Contacts of TB Patients screened for TB\n \n 2024-02-27 10:35:41 UTC\n \n 2024-02-27 10:36: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 2601\n select contact.person_id \n from \n (select B.person_id \n from obs B \n inner join \n (select person_id, max(obs_datetime) as latest_consultation \n from obs where concept_id = 5904 \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.latest_consultation = B.obs_datetime \n where concept_id = 5962 and value_coded = 2146 \n and A.latest_consultation = B.obs_datetime \n and voided = 0 \n group by B.person_id \n ) as contact\n','2024-02-27 16:05:41',4,'2024-02-27 16:06:09',4,0,NULL,NULL,NULL,'6733708e-c472-4c84-89a2-13e0938a8360'),(2602,'Presumptive TB contacts with bacteriologic result(s)','Presumptive TB contacts with bacteriologic test result (s)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Presumptive TB contacts with bacteriologic result(s)\n Presumptive TB contacts with bacteriologic test result (s)\n \n 2024-02-27 14:08:31 UTC\n \n 2024-02-27 14: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 2602\n \n select distinct Id \n FROM \n ( \n -- Bacteriologically confirmed Genotypic test results and Phenotypic test results \n select distinct person_id as Id \n From obs o \n where o.concept_id in (3814, 3815) \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.voided = 0 \n \n -- MTB not Detected \n and o.person_id in \n ( \n select distinct o.person_id \n from obs o \n inner join \n ( \n select oss.person_id as 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 in (5954,5433,5955,5956,5959) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.Id = o.person_id \n where o.concept_id in (3787,3805,3840,5957) \n and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n \n ) \n \n ) As Pulmonary_Bacteriologic\n','2024-02-27 19:38:31',4,'2024-02-27 19:46:55',4,0,NULL,NULL,NULL,'5c82cebb-b76f-4acd-a416-752578f29546'),(2603,'Contacts of TB Patients who are positive to a bacteriologic test ','Contacts of TB Patients who are positive to a bacteriologic test ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB Patients who are positive to a bacteriologic test \n Contacts of TB Patients who are positive to a bacteriologic test \n \n 2024-02-27 14:17:57 UTC\n \n 2024-02-27 17:56: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 2603\n select distinct Id \n FROM \n ( \n -- Bacteriologically results \n select distinct person_id as Id \n From obs o \n where o.concept_id = 5953 \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.voided = 0 \n \n -- MTB Detected \n and o.person_id in \n ( \n select distinct o.person_id \n from obs o \n inner join \n ( \n select oss.person_id as 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 in (5954,5433,5955,5956,5959) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.Id = o.person_id \n where o.concept_id in (3787,3805,3840,5957) \n and o.value_coded in (3816,3817,3718, 1738, 3828,3829,3830, 3831, 3832,3833,3834, 3835,3836, 3837,3838,3839) \n and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n \n ) \n \n ) As Pulmonary_Bacteriologic\n','2024-02-27 19:47:57',4,'2024-02-27 23:26:03',4,0,NULL,NULL,NULL,'c632d1d1-ddd1-40ca-bdfd-8df133511db3'),(2604,'Contacts of TB Patients who are positive bacteriologic test & started TB treatment','Contacts of TB Patients who are positive to a bacteriologic test and started on TB treatment','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB Patients who are positive bacteriologic test & started TB treatment\n Contacts of TB Patients who are positive to a bacteriologic test and started on TB treatment\n \n 2024-02-27 18:19:38 UTC\n \n 2024-02-27 18:20: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 2604\n select distinct Id \n FROM \n ( \n -- Bacteriologically results \n select distinct person_id as Id \n From obs o \n where o.concept_id = 5953 \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.voided = 0 \n \n -- MTB Detected \n and o.person_id in \n ( \n select distinct o.person_id \n from obs o \n inner join \n ( \n select oss.person_id as 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 in (5954,5433,5955,5956,5959) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.Id = o.person_id \n where o.concept_id in (3787,3805,3840,5957) \n and o.value_coded in (3816,3817,3718, 1738, 3828,3829,3830, 3831, 3832,3833,3834, 3835,3836, 3837,3838,3839) \n and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n \n ) \n \n ) As Pulmonary_Bacteriologic \n inner join ( \n select ob.person_id as pId \n FROM obs ob \n -- Pulmonary TB \n where ob.concept_id = 2237 \n AND cast(ob.value_datetime as date) >= CAST(:startDate AS DATE) \n and cast(ob.value_datetime as date) <= CAST(:endDate AS DATE) \n and ob.voided = 0 \n ) as Pulmonary \n on Pulmonary_Bacteriologic.Id = Pulmonary.pId\n','2024-02-27 23:49:38',4,'2024-02-27 23:50:06',4,0,NULL,NULL,NULL,'d2360af2-f13b-4b10-978f-5f230a0a83d7'),(2605,'Contacts of TB patients - Presumptive','Contacts of TB patients who have one or more signs and symptoms of TB (Presumptive)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB patients - Presumptive\n Contacts of TB patients who have one or more signs and symptoms of TB (Presumptive)\n \n 2024-02-27 18:31:50 UTC\n \n 2024-02-27 18:32: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 2605\n select ob.person_id as pId \n FROM obs ob \n where ob.concept_id = 5940 \n AND cast(ob.obs_datetime as date) >= CAST(:startDate AS DATE) \n and cast(ob.obs_datetime as date) <= CAST(:endDate AS DATE) \n and ob.voided = 0\n','2024-02-28 00:01:50',4,'2024-02-28 00:02:42',4,0,NULL,NULL,NULL,'17e19631-0322-48e3-8a42-352880f64b8f'),(2606,'Detection_Age','TB detection age groups','org.openmrs.module.reporting.indicator.dimension.Dimension','org.openmrs.module.reporting.indicator.dimension.CohortDefinitionDimension','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Detection_Age\n TB detection age groups\n \n 2024-02-27 18:42:36 UTC\n \n 2024-02-27 18:47:04 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n 2606\n \n \n 15+years\n \n \n \n \n maxAge\n 120\n \n \n minAge\n 15\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n 5-14yrs\n \n \n \n \n maxAge\n 14\n \n \n minAge\n 5\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n <5yrs\n \n \n \n \n maxAge\n 4\n \n \n minAge\n 0\n \n \n effectiveDate\n ${endDate}\n \n \n \n \n \n','2024-02-28 00:12:36',4,'2024-02-28 00:17:04',4,0,NULL,NULL,NULL,'c12ee61b-5bc3-4476-866b-3a5a1ac37038'),(2607,'Contacts of TB Patients','Contacts of TB Patients','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB Patients\n Contacts of TB Patients\n \n 2024-02-27 18:52:39 UTC\n \n 2024-02-27 18: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 2607\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 00:22:39',4,'2024-02-28 00:24:05',4,0,NULL,NULL,NULL,'ec97d270-a1a8-4d2c-ae71-b6ffcb555781'),(2610,'Contacts of TB Patients screened for TB','Contacts of TB Patients screened for TB','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB Patients screened for TB\n Contacts of TB Patients screened for TB\n \n 2024-02-27 19:00:00 UTC\n \n 2024-02-27 19:00: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 2610\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 00:30:00',4,'2024-02-28 00:30:51',4,0,NULL,NULL,NULL,'1fefae20-e24c-4809-97a3-0bb2942ca618'),(2611,'Contacts of TB patients -Presumptive','Contacts of TB patients who have one or more signs and symptoms of TB (Presumptive)','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB patients -Presumptive\n Contacts of TB patients who have one or more signs and symptoms of TB (Presumptive)\n \n 2024-02-27 19:02:10 UTC\n \n 2024-02-27 19:03: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 2611\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 00:32:10',4,'2024-02-28 00:33:04',4,0,NULL,NULL,NULL,'61a06072-21c6-492d-94c7-f59c8980ce28'),(2612,'Presumptive TB contacts with bacteriologic test result (s)','Presumptive TB contacts with bacteriologic test result (s)','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Presumptive TB contacts with bacteriologic test result (s)\n Presumptive TB contacts with bacteriologic test result (s)\n \n 2024-02-27 19:04:19 UTC\n \n 2024-02-27 19:10: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 2612\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 00:34:19',4,'2024-02-28 00:40:31',4,0,NULL,NULL,NULL,'93c6d789-932b-4b13-903a-1c238427492c'),(2614,'Contacts of TB Patients who are positive to a bacteriologic test ','Contacts of TB Patients who are positive to a bacteriologic test ','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB Patients who are positive to a bacteriologic test \n Contacts of TB Patients who are positive to a bacteriologic test \n \n 2024-02-27 19:11:53 UTC\n \n 2024-02-27 19:12: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 2614\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 00:41:53',4,'2024-02-28 00:42:39',4,0,NULL,NULL,NULL,'ad43ca8a-5327-49d6-82a9-d4a5b532e54e'),(2615,'Contacts of TB Patients who are positive to a bacteriologic test and started on TB treatment','Contacts of TB Patients who are positive to a bacteriologic test and started on TB treatment','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Contacts of TB Patients who are positive to a bacteriologic test and started on TB treatment\n Contacts of TB Patients who are positive to a bacteriologic test and started on TB treatment\n \n 2024-02-27 19:13:47 UTC\n \n 2024-02-27 19: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 2615\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 00:43:47',4,'2024-02-28 00:44:36',4,0,NULL,NULL,NULL,'eecb27c4-5eea-4c61-8093-2e76f27c5733'),(2616,'TB Case Detection - Block 2: Contact Tracing and screening ','TB Case Detection - Block 2: Contact Tracing and screening ','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Case Detection - Block 2: Contact Tracing and screening \n TB Case Detection - Block 2: Contact Tracing and screening \n \n 2024-02-27 19:18:00 UTC\n \n 2024-02-27 19:18: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 2616\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','2024-02-28 00:48:00',4,'2024-02-28 00:48:20',4,0,NULL,NULL,NULL,'18beaf66-8afb-4c42-85f3-6a4f9e6e4c86'),(2617,'TB Case Detection - Block 2: Contact Tracing and screening 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 Case Detection - Block 2: Contact Tracing and screening Data Set\n \n 2024-02-27 19:18:20 UTC\n \n 2024-02-27 19: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 2617\n \n \n Detection_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n AlPosBacTB\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 AllBacRes\n \n \n \n \n \n \n \n \n \n AllConPres\n \n \n \n \n \n \n \n \n \n AllConScre\n \n \n \n \n \n \n \n \n \n AllContact\n \n \n \n \n \n \n \n \n \n AllPosBact\n \n \n \n \n \n \n \n \n \n BacRes5-14\n \n \n \n \n Detection_Age\n 5-14yrs\n \n \n \n \n \n BacRes<5ys\n \n \n \n \n Detection_Age\n <5yrs\n \n \n \n \n \n Con15+ys\n \n \n \n \n Detection_Age\n 15+years\n \n \n \n \n \n ConPre15+y\n \n \n \n \n \n \n ConPre5-14\n \n \n \n \n \n \n ConPres<5y\n \n \n \n \n \n \n ConScr15+y\n \n \n \n \n \n \n ConScr5-14\n \n \n \n \n \n \n ConScr<5ys\n \n \n \n \n \n \n Cont5-14ys\n \n \n \n \n \n \n Cont<5ys\n \n \n \n \n \n \n PoBaTB5-14\n \n \n \n \n \n \n PoBacTB15+\n \n \n \n \n \n \n PosBac15+y\n \n \n \n \n \n \n PosBac5-14\n \n \n \n \n \n \n PosBac<5ys\n \n \n \n \n \n \n PosBacTB<5\n \n \n \n \n \n \n','2024-02-28 00:48:20',4,'2024-02-28 01:18:21',4,0,NULL,NULL,NULL,'8ce17921-9b17-4c08-9bfc-679a5d0d56da'),(2618,'TB patients given 2RHZE/4RHE weighing 30-39kg','TB patients given 2RHZE/4RHE weighing 30-39kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing 30-39kg\n TB patients given 2RHZE/4RHE weighing 30-39kg\n \n 2024-02-28 09:00:45 UTC\n \n 2024-02-28 09:01: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 2618\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6002 -- 2RHZE/4RHE \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=30 and _weight < 40 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:30:45',4,'2024-02-28 14:31:30',4,0,NULL,NULL,NULL,'bce1bee1-bb3f-4a76-afef-2247f4cd563d'),(2619,'TB patients given 2RHZE/4RHE weighing 40-54kg','TB patients given 2RHZE/4RHE weighing 40-54kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing 40-54kg\n TB patients given 2RHZE/4RHE weighing 40-54kg\n \n 2024-02-28 09:03:00 UTC\n \n 2024-02-28 09:03: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 2619\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6002 -- 2RHZE/4RHE \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=40 and _weight < 55 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:33:00',4,'2024-02-28 14:33:22',4,0,NULL,NULL,NULL,'1e603efc-b71c-45c5-8c9b-8f3126d88455'),(2620,'TB patients given 2RHZE/4RHE weighing 55-70kg','TB patients given 2RHZE/4RHE weighing 55-70kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing 55-70kg\n TB patients given 2RHZE/4RHE weighing 55-70kg\n \n 2024-02-28 09:03:53 UTC\n \n 2024-02-28 09:04: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 2620\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6002 -- 2RHZE/4RHE \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=55 and _weight <= 70 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:33:53',4,'2024-02-28 14:34:42',4,0,NULL,NULL,NULL,'7a53ac46-5c90-4320-83ff-2f59647d980f'),(2621,'TB patients given 2RHZE/4RHE weighing > 70','TB patients given 2RHZE/4RHE weighing > 70','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing > 70\n TB patients given 2RHZE/4RHE weighing > 70\n \n 2024-02-28 09:05:44 UTC\n \n 2024-02-28 09: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 2621\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6002 -- 2RHZE/4RHE \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight > 70 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:35:44',4,'2024-02-28 14:36:26',4,0,NULL,NULL,NULL,'fe5b0998-1225-4b7e-b565-e15fa88e7ca7'),(2622,'TB patients given 2HPMZ/2HPM weighing 40-50kg','TB patients given 2HPMZ/2HPM weighing 40-50kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HPMZ/2HPM weighing 40-50kg\n TB patients given 2HPMZ/2HPM weighing 40-50kg\n \n 2024-02-28 09:08:25 UTC\n \n 2024-02-28 09:08: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 2622\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6003 -- 2HPMZ/2HPM \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=40 and _weight < 50 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 14:38:25',4,'2024-02-28 14:38:53',4,0,NULL,NULL,NULL,'97d1eb39-6c72-4cd7-85f2-a7667daea615'),(2623,'TB patients given 2HPMZ/2HPM weighing 50-65kg','TB patients given 2HPMZ/2HPM weighing 50-65kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HPMZ/2HPM weighing 50-65kg\n TB patients given 2HPMZ/2HPM weighing 50-65kg\n \n 2024-02-28 09:09:48 UTC\n \n 2024-02-28 09:10: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 2623\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6003 -- 2HPMZ/2HPM \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=50 and _weight < 65 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 14:39:48',4,'2024-02-28 14:40:58',4,0,NULL,NULL,NULL,'4698f622-e7a9-4dd9-8c2d-6af54419f71f'),(2624,'TB patients given 2HPMZ/2HPM weighing > 65kg','TB patients given 2HPMZ/2HPM weighing > 65kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HPMZ/2HPM weighing > 65kg\n TB patients given 2HPMZ/2HPM weighing > 65kg\n \n 2024-02-28 09:11:30 UTC\n \n 2024-02-28 09:12: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 2624\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6003 -- 2HPMZ/2HPM \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=65 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:41:30',4,'2024-02-28 14:42:01',4,0,NULL,NULL,NULL,'707a44a5-5cd1-46d8-9880-4c4396914acc'),(2625,'TB patients given 2RHZE/4HR weighing <2kg','TB patients given 2RHZE/4HR weighing <2kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing <2kg\n TB patients given 2RHZE/4HR weighing <2kg\n \n 2024-02-28 09:16:33 UTC\n \n 2024-02-28 09:18: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 2625\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight < 2 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 14:46:33',4,'2024-02-28 14:48:07',4,0,NULL,NULL,NULL,'4c663664-65db-4048-8554-4546b580ff2f'),(2626,'TB patients given 2RHZE/4HR weighing 2-2.9kg','TB patients given 2RHZE/4HR weighing 2-2.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 2-2.9kg\n TB patients given 2RHZE/4HR weighing 2-2.9kg\n \n 2024-02-28 09:17:03 UTC\n \n 2024-02-28 09:18: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 2626\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=2 and _weight <=2.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 14:47:03',4,'2024-02-28 14:48:56',4,0,NULL,NULL,NULL,'bcc6e6f5-8e74-4a51-bf4e-74f9aa16c937'),(2627,'TB patients given 2RHZE/4HR weighing 3-3.9kg','TB patients given 2RHZE/4HR weighing 3-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 3-3.9kg\n TB patients given 2RHZE/4HR weighing 3-3.9kg\n \n 2024-02-28 09:17:29 UTC\n \n 2024-02-28 09:19: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 2627\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=3 and _weight <=3.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 14:47:29',4,'2024-02-28 14:49:26',4,0,NULL,NULL,NULL,'5f931adb-9e99-4e78-a063-02bd6d424205'),(2628,'TB patients given 2RHZE/4HR weighing 4-7.9kg','TB patients given 2RHZE/4HR weighing 4-7.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 4-7.9kg\n TB patients given 2RHZE/4HR weighing 4-7.9kg\n \n 2024-02-28 09:20:41 UTC\n \n 2024-02-28 09: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 2628\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=4 and _weight <=7.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 14:50:41',4,'2024-02-28 14:52:44',4,0,NULL,NULL,NULL,'e45460ed-89cd-4be9-a60b-b3b96c18690c'),(2629,'TB patients given 2RHZE/4HR weighing 8-11.9kg','TB patients given 2RHZE/4HR weighing 8-11.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 8-11.9kg\n TB patients given 2RHZE/4HR weighing 8-11.9kg\n \n 2024-02-28 09:21:07 UTC\n \n 2024-02-28 09:23: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 2629\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=8 and _weight <=11.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 14:51:07',4,'2024-02-28 14:53:25',4,0,NULL,NULL,NULL,'abc8ec30-9c64-4b20-90d5-84d305425137'),(2630,'TB patients given 2RHZE/4HR weighing 12-15.9kg','TB patients given 2RHZE/4HR weighing 12-15.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 12-15.9kg\n TB patients given 2RHZE/4HR weighing 12-15.9kg\n \n 2024-02-28 09:21:43 UTC\n \n 2024-02-28 09:24: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 2630\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=12 and _weight <=15.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 14:51:43',4,'2024-02-28 14:54:08',4,0,NULL,NULL,NULL,'52ec3a8d-b3e6-41dc-aa67-2ff1a07dfd2d'),(2631,'TB patients given 2RHZE/4HR weighing 16-24.9kg','TB patients given 2RHZE/4HR weighing 16-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 16-24.9kg\n TB patients given 2RHZE/4HR weighing 16-24.9kg\n \n 2024-02-28 09:24:47 UTC\n \n 2024-02-28 09:26: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 2631\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=16 and _weight <=24.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:54:47',4,'2024-02-28 14:56:48',4,0,NULL,NULL,NULL,'aaaa184e-66a3-41ee-805d-63a160e900d7'),(2632,'TB patients given 2RHZE/4HR weighing 25-<30kg','TB patients given 2RHZE/4HR weighing 25-<30kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 25-<30kg\n TB patients given 2RHZE/4HR weighing 25-<30kg\n \n 2024-02-28 09:25:32 UTC\n \n 2024-02-28 09:27: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 2632\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=25 and _weight <30 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:55:32',4,'2024-02-28 14:57:11',4,0,NULL,NULL,NULL,'0f4326f5-cd2a-4800-a7cb-fe455816074e'),(2633,'TB patients given 2RHZE/4HR weighing 30-<35kg','TB patients given 2RHZE/4HR weighing 30-<35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 30-<35kg\n TB patients given 2RHZE/4HR weighing 30-<35kg\n \n 2024-02-28 09:25:58 UTC\n \n 2024-02-28 09:27: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 2633\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=30 and _weight <35 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:55:58',4,'2024-02-28 14:57:39',4,0,NULL,NULL,NULL,'a8c81b22-814f-4ec1-870c-a46e92de3ee2'),(2634,'TB patients given 2RHZE/4HR weighing 35-<50kg','TB patients given 2RHZE/4HR weighing 35-<50kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 35-<50kg\n TB patients given 2RHZE/4HR weighing 35-<50kg\n \n 2024-02-28 09:28:44 UTC\n \n 2024-02-28 09:30: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 2634\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=35 and _weight <50 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:58:44',4,'2024-02-28 15:00:43',4,0,NULL,NULL,NULL,'780376a9-7a64-41f5-8f4d-0bcae15e9ca9'),(2635,'TB patients given 2RHZE/4HR weighing 50-<65kg','TB patients given 2RHZE/4HR weighing 50-<65kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 50-<65kg\n TB patients given 2RHZE/4HR weighing 50-<65kg\n \n 2024-02-28 09:29:39 UTC\n \n 2024-02-28 09: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 2635\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=50 and _weight <65 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 14:59:39',4,'2024-02-28 15:01:03',4,0,NULL,NULL,NULL,'7adf4555-6be7-4db8-911c-41e8087ab25f'),(2636,'TB patients given 2RHZE/4HR weighing >65kg','TB patients given 2RHZE/4HR weighing >65kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing >65kg\n TB patients given 2RHZE/4HR weighing >65kg\n \n 2024-02-28 09:30:09 UTC\n \n 2024-02-28 09:31: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 2636\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6004 -- 2RHZE/4HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=65 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:00:09',4,'2024-02-28 15:01:20',4,0,NULL,NULL,NULL,'3ba100cc-0cf9-491d-a702-3382611c1f47'),(2637,'TB patients given 2HRE/10HR weighing < 2kg','TB patients given 2HRE/10HR weighing < 2kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing < 2kg\n TB patients given 2HRE/10HR weighing < 2kg\n \n 2024-02-28 09:46:22 UTC\n \n 2024-02-28 09:47: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 2637\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight<2 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:16:22',4,'2024-02-28 15:17:53',4,0,NULL,NULL,NULL,'c7f2046d-c7a7-4d48-9c85-2a455c7dbdc0'),(2638,'TB patients given 2HRE/10HR weighing 2-2.9kg','TB patients given 2HRE/10HR weighing 2-2.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 2-2.9kg\n TB patients given 2HRE/10HR weighing 2-2.9kg\n \n 2024-02-28 09:46:56 UTC\n \n 2024-02-28 09:48: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 2638\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=2 and _weight <=2.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:16:56',4,'2024-02-28 15:18:18',4,0,NULL,NULL,NULL,'de0d0c97-70f7-4883-bc11-e831a85a64bd'),(2639,'TB patients given 2HRE/10HR weighing 3-3.9kg','TB patients given 2HRE/10HR weighing 3-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 3-3.9kg\n TB patients given 2HRE/10HR weighing 3-3.9kg\n \n 2024-02-28 09:47:20 UTC\n \n 2024-02-28 09:48: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 2639\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=3 and _weight <=3.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:17:20',4,'2024-02-28 15:18:37',4,0,NULL,NULL,NULL,'8a6d80b4-4f5f-416d-8242-73f18ca89178'),(2640,'TB patients given 2HRE/10HR weighing 4-7.9kg','TB patients given 2HRE/10HR weighing 4-7.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 4-7.9kg\n TB patients given 2HRE/10HR weighing 4-7.9kg\n \n 2024-02-28 09:49:19 UTC\n \n 2024-02-28 09:50: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 2640\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=4 and _weight <=7.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:19:19',4,'2024-02-28 15:20:56',4,0,NULL,NULL,NULL,'38551c29-6e79-4f40-9411-9beecdee568e'),(2641,'TB patients given 2HRE/10HR weighing 8-11.9kg','TB patients given 2HRE/10HR weighing 8-11.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 8-11.9kg\n TB patients given 2HRE/10HR weighing 8-11.9kg\n \n 2024-02-28 09:49:56 UTC\n \n 2024-02-28 09:51: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 2641\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=8 and _weight <=11.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:19:56',4,'2024-02-28 15:21:15',4,0,NULL,NULL,NULL,'59ff1d6e-fe8b-4ca9-9b15-10937a9fa334'),(2642,'TB patients given 2HRE/10HR weighing 12-15.9kg','TB patients given 2HRE/10HR weighing 12-15.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 12-15.9kg\n TB patients given 2HRE/10HR weighing 12-15.9kg\n \n 2024-02-28 09:50:27 UTC\n \n 2024-02-28 09:51: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 2642\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=12 and _weight <=15.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:20:27',4,'2024-02-28 15:21:35',4,0,NULL,NULL,NULL,'1fab63d8-a077-4f3d-b679-8ea75eefc879'),(2643,'TB patients given 2HRE/10HR weighing 16-24.9kg','TB patients given 2HRE/10HR weighing 16-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 16-24.9kg\n TB patients given 2HRE/10HR weighing 16-24.9kg\n \n 2024-02-28 09:52:51 UTC\n \n 2024-02-28 09:54: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 2643\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=16 and _weight <=24.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:22:51',4,'2024-02-28 15:24:31',4,0,NULL,NULL,NULL,'e3ca9790-a1cc-4ede-adb2-2adf7417ef0e'),(2644,'TB patients given 2HRE/10HR weighing 25-<30kg','TB patients given 2HRE/10HR weighing 25-<30kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 25-<30kg\n TB patients given 2HRE/10HR weighing 25-<30kg\n \n 2024-02-28 09:53:35 UTC\n \n 2024-02-28 09:54: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 2644\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=25 and _weight <30 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:23:35',4,'2024-02-28 15:24:52',4,0,NULL,NULL,NULL,'61d82671-e514-447c-9f93-6ff18cefcc43'),(2645,'TB patients given 2HRE/10HR weighing 30-<35kg','TB patients given 2HRE/10HR weighing 30-<35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 30-<35kg\n TB patients given 2HRE/10HR weighing 30-<35kg\n \n 2024-02-28 09:53:58 UTC\n \n 2024-02-28 09:55: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 2645\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=30 and _weight <35 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:23:58',4,'2024-02-28 15:25:23',4,0,NULL,NULL,NULL,'ba68f071-b28c-4593-9eb5-d766c4059246'),(2646,'TB patients given 2HRE/10HR weighing 35-<50kg','TB patients given 2HRE/10HR weighing 35-<50kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 35-<50kg\n TB patients given 2HRE/10HR weighing 35-<50kg\n \n 2024-02-28 09:56:05 UTC\n \n 2024-02-28 09:57: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 2646\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=35 and _weight <50 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:26:05',4,'2024-02-28 15:27:36',4,0,NULL,NULL,NULL,'97a65448-6d14-44c7-b5f6-c9239129cc04'),(2647,'TB patients given 2HRE/10HR weighing 50-<65kg','TB patients given 2HRE/10HR weighing 50-<65kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 50-<65kg\n TB patients given 2HRE/10HR weighing 50-<65kg\n \n 2024-02-28 09:58:05 UTC\n \n 2024-02-28 09:59: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 2647\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=50 and _weight <65 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:28:05',4,'2024-02-28 15:29:08',4,0,NULL,NULL,NULL,'d55f2b31-4ae3-474d-888a-e00f28cb793d'),(2648,'TB patients given 2HRE/10HR weighing > 65kg','TB patients given 2HRE/10HR weighing > 65kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing > 65kg\n TB patients given 2HRE/10HR weighing > 65kg\n \n 2024-02-28 09:58:37 UTC\n \n 2024-02-28 09: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 2648\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6006 -- 2HRE/10HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=65 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:28:37',4,'2024-02-28 15:29:30',4,0,NULL,NULL,NULL,'1f23c88a-059b-4f38-b2eb-fc6799b4f222'),(2649,'TB patients given 2RHZE/2HR weighing < 2kg','TB patients given 2RHZE/2HR weighing < 2kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing < 2kg\n TB patients given 2RHZE/2HR weighing < 2kg\n \n 2024-02-28 10:01:29 UTC\n \n 2024-02-28 10:02: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 2649\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight<2 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 15:31:29',4,'2024-02-28 15:32:50',4,0,NULL,NULL,NULL,'8d42e0e8-c79a-4f69-abc6-4fa27df65a30'),(2650,'TB patients given 2RHZE/2HR weighing 2-2.9kg','TB patients given 2RHZE/2HR weighing 2-2.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 2-2.9kg\n TB patients given 2RHZE/2HR weighing 2-2.9kg\n \n 2024-02-28 10:01:54 UTC\n \n 2024-02-28 10:03: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 2650\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=2 and _weight <=2.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 15:31:54',4,'2024-02-28 15:33:05',4,0,NULL,NULL,NULL,'b2fe9c79-18fe-49be-aa3c-b7bfbd65ba1c'),(2651,'TB patients given 2RHZE/2HR weighing 3-3.9kg','TB patients given 2RHZE/2HR weighing 3-3.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 3-3.9kg\n TB patients given 2RHZE/2HR weighing 3-3.9kg\n \n 2024-02-28 10:02:16 UTC\n \n 2024-02-28 10:03: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 2651\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=3 and _weight <=3.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 15:32:16',4,'2024-02-28 15:33:21',4,0,NULL,NULL,NULL,'22385e11-6674-42cb-9da8-78d2340fb975'),(2652,'B patients given 2RHZE/2HR weighing 4-7.9kg','B patients given 2RHZE/2HR weighing 4-7.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n B patients given 2RHZE/2HR weighing 4-7.9kg\n B patients given 2RHZE/2HR weighing 4-7.9kg\n \n 2024-02-28 10:04:18 UTC\n \n 2024-02-28 10:05: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 2652\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=4 and _weight <=7.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 15:34:18',4,'2024-02-28 15:35:37',4,0,NULL,NULL,NULL,'356dbe3c-dd76-4e39-b486-3e86492b4eb0'),(2653,'B patients given 2RHZE/2HR weighing 8-11.9kg','B patients given 2RHZE/2HR weighing 8-11.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n B patients given 2RHZE/2HR weighing 8-11.9kg\n B patients given 2RHZE/2HR weighing 8-11.9kg\n \n 2024-02-28 10:04:50 UTC\n \n 2024-02-28 10:06: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 2653\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=8 and _weight <=11.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 15:34:50',4,'2024-02-28 15:36:00',4,0,NULL,NULL,NULL,'3d88ce54-fe6f-45ec-9628-303ede656df6'),(2654,'B patients given 2RHZE/2HR weighing 12-15.9kg','B patients given 2RHZE/2HR weighing 12-15.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n B patients given 2RHZE/2HR weighing 12-15.9kg\n B patients given 2RHZE/2HR weighing 12-15.9kg\n \n 2024-02-28 10:05:14 UTC\n \n 2024-02-28 10:06: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 2654\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=12 and _weight <=15.9 \n)weight__ \nON regimen.Id = weight__.Id \n\n','2024-02-28 15:35:14',4,'2024-02-28 15:36:38',4,0,NULL,NULL,NULL,'f072dc00-cc6a-4c1d-b049-3d71fdd7c418'),(2655,'TB patients given 2RHZE/2HR weighing 4-7.9kg','TB patients given 2RHZE/2HR weighing 4-7.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 4-7.9kg\n TB patients given 2RHZE/2HR weighing 4-7.9kg\n \n 2024-02-28 10:10:03 UTC\n \n 2024-02-28 10:11: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 2655\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=4 and _weight <=7.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:40:03',4,'2024-02-28 15:41:16',4,0,NULL,NULL,NULL,'5d170b44-4744-44a0-8b5c-9a147276a165'),(2656,'TB patients given 2RHZE/2HR weighing 8-11.9kg','TB patients given 2RHZE/2HR weighing 8-11.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 8-11.9kg\n TB patients given 2RHZE/2HR weighing 8-11.9kg\n \n 2024-02-28 10:10:27 UTC\n \n 2024-02-28 10:11: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 2656\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=8 and _weight <=11.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:40:27',4,'2024-02-28 15:41:41',4,0,NULL,NULL,NULL,'4c12f685-7ba2-4a98-85d9-e8c718af019c'),(2657,'TB patients given 2RHZE/2HR weighing 12-15.9kg','TB patients given 2RHZE/2HR weighing 12-15.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 12-15.9kg\n TB patients given 2RHZE/2HR weighing 12-15.9kg\n \n 2024-02-28 10:10:49 UTC\n \n 2024-02-28 10:11: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 2657\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=12 and _weight <=15.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:40:49',4,'2024-02-28 15:41:59',4,0,NULL,NULL,NULL,'2da2a070-b7ba-4cd7-90c5-41cddf07a601'),(2658,'TB patients given 2RHZE/2HR weighing 16-24.9kg','TB patients given 2RHZE/2HR weighing 16-24.9kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 16-24.9kg\n TB patients given 2RHZE/2HR weighing 16-24.9kg\n \n 2024-02-28 10:12:34 UTC\n \n 2024-02-28 10:13: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 2658\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=16 and _weight <=24.9 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:42:34',4,'2024-02-28 15:43:58',4,0,NULL,NULL,NULL,'ecfd9cec-ff1f-4d86-b760-18ee712a0d36'),(2659,'TB patients given 2RHZE/2HR weighing 25-<30kg','TB patients given 2RHZE/2HR weighing 25-<30kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 25-<30kg\n TB patients given 2RHZE/2HR weighing 25-<30kg\n \n 2024-02-28 10:13:03 UTC\n \n 2024-02-28 10: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 2659\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=25 and _weight <30 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:43:03',4,'2024-02-28 15:44:18',4,0,NULL,NULL,NULL,'66c43d8e-18e2-41e5-a0b0-501a2b508a22'),(2660,'TB patients given 2RHZE/2HR weighing 30-<35kg','TB patients given 2RHZE/2HR weighing 30-<35kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 30-<35kg\n TB patients given 2RHZE/2HR weighing 30-<35kg\n \n 2024-02-28 10:13:24 UTC\n \n 2024-02-28 10:14: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 2660\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=30 and _weight <35 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:43:24',4,'2024-02-28 15:44:35',4,0,NULL,NULL,NULL,'362a2af4-9cdc-4380-8631-4188d1354417'),(2661,'TB patients given 2RHZE/2HR weighing 35-<50kg','TB patients given 2RHZE/2HR weighing 35-<50kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 35-<50kg\n TB patients given 2RHZE/2HR weighing 35-<50kg\n \n 2024-02-28 10:15:06 UTC\n \n 2024-02-28 10:16: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 2661\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=35 and _weight <50 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:45:06',4,'2024-02-28 15:46:29',4,0,NULL,NULL,NULL,'210d7eb7-846b-42fe-a1e5-c47bc1450cb6'),(2662,'TB patients given 2RHZE/2HR weighing 50-<65kg','TB patients given 2RHZE/2HR weighing 50-<65kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 50-<65kg\n TB patients given 2RHZE/2HR weighing 50-<65kg\n \n 2024-02-28 10:15:34 UTC\n \n 2024-02-28 10:17: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 2662\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=50 and _weight <65 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:45:34',4,'2024-02-28 15:47:01',4,0,NULL,NULL,NULL,'8662ce61-9594-487c-9c1c-c683a2f95180'),(2663,'TB patients given 2RHZE/2HR weighing >65kg','TB patients given 2RHZE/2HR weighing >65kg','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing >65kg\n TB patients given 2RHZE/2HR weighing >65kg\n \n 2024-02-28 10:16:01 UTC\n \n 2024-02-28 10:36: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 2663\n select regimen.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4218 and o.value_coded = 6005 -- 2RHZE/2HR \n 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 group by person_id)regimen \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 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)AS weight_ \n where _weight>=65 \n)weight__ \nON regimen.Id = weight__.Id\n','2024-02-28 15:46:01',4,'2024-02-28 16:06:50',4,0,NULL,NULL,NULL,'d0c91360-93f7-4b62-a335-38d1f9e8e458'),(2664,'TB patients given 2HPMZ/2HPM weighing 40-50kg','TB patients given 2HPMZ/2HPM weighing 40-50kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HPMZ/2HPM weighing 40-50kg\n TB patients given 2HPMZ/2HPM weighing 40-50kg\n \n 2024-02-28 10:38:37 UTC\n \n 2024-02-28 10:40: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 2664\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:08:37',4,'2024-02-28 16:10:21',4,0,NULL,NULL,NULL,'267131cd-92f8-4d89-9153-7666479e3d96'),(2665,'TB patients given 2HPMZ/2HPM weighing 50-65kg','TB patients given 2HPMZ/2HPM weighing 50-65kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HPMZ/2HPM weighing 50-65kg\n TB patients given 2HPMZ/2HPM weighing 50-65kg\n \n 2024-02-28 10:40:43 UTC\n \n 2024-02-28 10:42: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 2665\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:10:43',4,'2024-02-28 16:12:38',4,0,NULL,NULL,NULL,'a2cce7b4-84b0-407c-a850-045310956d08'),(2666,'TB patients given 2HPMZ/2HPM weighing > 65kg','TB patients given 2HPMZ/2HPM weighing > 65kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HPMZ/2HPM weighing > 65kg\n TB patients given 2HPMZ/2HPM weighing > 65kg\n \n 2024-02-28 10:41:20 UTC\n \n 2024-02-28 10:43: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 2666\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:11:20',4,'2024-02-28 16:13:29',4,0,NULL,NULL,NULL,'66aa10a3-2291-4f8a-a710-af0231160982'),(2667,'TB patients given 2RHZE/4RHE weighing 30-39kg','TB patients given 2RHZE/4RHE weighing 30-39kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing 30-39kg\n TB patients given 2RHZE/4RHE weighing 30-39kg\n \n 2024-02-28 10:45:02 UTC\n \n 2024-02-28 10:47: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 2667\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:15:02',4,'2024-02-28 16:17:52',4,0,NULL,NULL,NULL,'507430f5-598c-485d-876a-0e1dbcdaea22'),(2668,'TB patients given 2RHZE/4RHE weighing 40-54kg','TB patients given 2RHZE/4RHE weighing 40-54kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing 40-54kg\n TB patients given 2RHZE/4RHE weighing 40-54kg\n \n 2024-02-28 10:46:01 UTC\n \n 2024-02-28 10: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 2668\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:16:01',4,'2024-02-28 16:18:15',4,0,NULL,NULL,NULL,'2d8b3440-8b64-4836-8097-0ee78b1421f9'),(2669,'TB patients given 2RHZE/4RHE weighing 55-70kg','TB patients given 2RHZE/4RHE weighing 55-70kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing 55-70kg\n TB patients given 2RHZE/4RHE weighing 55-70kg\n \n 2024-02-28 10:47:03 UTC\n \n COUNT\n','2024-02-28 16:17:03',4,NULL,NULL,0,NULL,NULL,NULL,'77aaf4be-b225-465a-b3dc-685757328958'),(2670,'TB patients given 2RHZE/4RHE weighing 55-70kg','TB patients given 2RHZE/4RHE weighing 55-70kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing 55-70kg\n TB patients given 2RHZE/4RHE weighing 55-70kg\n \n 2024-02-28 10:47:06 UTC\n \n 2024-02-28 10:49: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 2670\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:17:06',4,'2024-02-28 16:19:09',4,0,NULL,NULL,NULL,'4ca65f2c-58a1-46f2-be7d-d2e0b8b52eca'),(2671,'TB patients given 2RHZE/4RHE weighing > 70','TB patients given 2RHZE/4RHE weighing > 70','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4RHE weighing > 70\n TB patients given 2RHZE/4RHE weighing > 70\n \n 2024-02-28 10:48:45 UTC\n \n 2024-02-28 10:51: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 2671\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:18:45',4,'2024-02-28 16:21:07',4,0,NULL,NULL,NULL,'aacf0718-0185-42a7-8e9f-dc32a196d708'),(2672,'TB patients given 2RHZE/4HR weighing <2kg','TB patients given 2RHZE/4HR weighing <2kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing <2kg\n TB patients given 2RHZE/4HR weighing <2kg\n \n 2024-02-28 10:52:59 UTC\n \n 2024-02-28 10:55: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 2672\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:22:59',4,'2024-02-28 16:25:06',4,0,NULL,NULL,NULL,'fcef6215-4d11-4edb-a132-3a001295eac7'),(2673,'TB patients given 2RHZE/4HR weighing 2-2.9kg','TB patients given 2RHZE/4HR weighing 2-2.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 2-2.9kg\n TB patients given 2RHZE/4HR weighing 2-2.9kg\n \n 2024-02-28 10:53:34 UTC\n \n COUNT\n','2024-02-28 16:23:34',4,NULL,NULL,0,NULL,NULL,NULL,'a0f2d45a-30f4-4c5f-af64-3a6ccb151c33'),(2674,'TB patients given 2RHZE/4HR weighing 2-2.9kg','TB patients given 2RHZE/4HR weighing 2-2.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 2-2.9kg\n TB patients given 2RHZE/4HR weighing 2-2.9kg\n \n 2024-02-28 10:53:37 UTC\n \n 2024-02-28 10:57: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 2674\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:23:37',4,'2024-02-28 16:27:48',4,0,NULL,NULL,NULL,'a5aff9a2-2ff6-49ce-a1f9-5b2c07874d5c'),(2675,'TB patients given 2RHZE/4HR weighing 3-3.9kg','TB patients given 2RHZE/4HR weighing 3-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 3-3.9kg\n TB patients given 2RHZE/4HR weighing 3-3.9kg\n \n 2024-02-28 10:56:04 UTC\n \n 2024-02-28 10:58: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 2675\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:26:04',4,'2024-02-28 16:28:10',4,0,NULL,NULL,NULL,'06a8c0b0-b7a3-4443-b168-9816354d5519'),(2676,'TB patients given 2RHZE/4HR weighing 4-7.9kg','TB patients given 2RHZE/4HR weighing 4-7.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 4-7.9kg\n TB patients given 2RHZE/4HR weighing 4-7.9kg\n \n 2024-02-28 10:57:21 UTC\n \n 2024-02-28 10:59: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 2676\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:27:21',4,'2024-02-28 16:29:15',4,0,NULL,NULL,NULL,'fba7f805-6a0e-4a02-89fe-d8fe6491ff51'),(2677,'TB patients given 2RHZE/4HR weighing 8-11.9kg','TB patients given 2RHZE/4HR weighing 8-11.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 8-11.9kg\n TB patients given 2RHZE/4HR weighing 8-11.9kg\n \n 2024-02-28 10:59:49 UTC\n \n 2024-02-28 11:03: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 2677\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:29:49',4,'2024-02-28 16:33:52',4,0,NULL,NULL,NULL,'acb3c52b-cd20-4b33-8b0e-f8f8865d283c'),(2678,'TB patients given 2RHZE/4HR weighing 12-15.9kg','TB patients given 2RHZE/4HR weighing 12-15.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 12-15.9kg\n TB patients given 2RHZE/4HR weighing 12-15.9kg\n \n 2024-02-28 11:00:16 UTC\n \n 2024-02-28 11:04: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 2678\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:30:16',4,'2024-02-28 16:34:11',4,0,NULL,NULL,NULL,'af2dc223-8a19-46b1-b8ae-add6e943f891'),(2679,'TB patients given 2RHZE/4HR weighing 16-24.9kg','TB patients given 2RHZE/4HR weighing 16-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 16-24.9kg\n TB patients given 2RHZE/4HR weighing 16-24.9kg\n \n 2024-02-28 11:00:43 UTC\n \n 2024-02-28 11:04: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 2679\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:30:43',4,'2024-02-28 16:34:34',4,0,NULL,NULL,NULL,'693ddd70-5db7-46ba-8195-670f174b867f'),(2680,'TB patients given 2RHZE/4HR weighing 25-<30kg','TB patients given 2RHZE/4HR weighing 25-<30kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 25-<30kg\n TB patients given 2RHZE/4HR weighing 25-<30kg\n \n 2024-02-28 11:01:10 UTC\n \n 2024-02-28 11: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 2680\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:31:10',4,'2024-02-28 16:34:58',4,0,NULL,NULL,NULL,'2bd66740-4941-4932-8876-43e12c912ef0'),(2681,'TB patients given 2RHZE/4HR weighing 30-<35kg','TB patients given 2RHZE/4HR weighing 30-<35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 30-<35kg\n TB patients given 2RHZE/4HR weighing 30-<35kg\n \n 2024-02-28 11:05:44 UTC\n \n 2024-02-28 11:08: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 2681\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:35:44',4,'2024-02-28 16:38:52',4,0,NULL,NULL,NULL,'5201f808-7174-4785-b5a8-fb855cb1bc00'),(2682,'TB patients given 2RHZE/4HR weighing 35-<50kg','TB patients given 2RHZE/4HR weighing 35-<50kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 35-<50kg\n TB patients given 2RHZE/4HR weighing 35-<50kg\n \n 2024-02-28 11:07:34 UTC\n \n 2024-02-28 11:10: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 2682\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:37:34',4,'2024-02-28 16:40:34',4,0,NULL,NULL,NULL,'663aa7b1-0169-4cd3-aabb-1d33b0a54706'),(2683,'TB patients given 2RHZE/4HR weighing 50-<65kg','TB patients given 2RHZE/4HR weighing 50-<65kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing 50-<65kg\n TB patients given 2RHZE/4HR weighing 50-<65kg\n \n 2024-02-28 11:07:58 UTC\n \n 2024-02-28 11: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 2683\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:37:58',4,'2024-02-28 16:40:49',4,0,NULL,NULL,NULL,'a07688e5-85a2-468b-9dc8-13a8c1100b47'),(2684,'TB patients given 2RHZE/4HR weighing >65kg','TB patients given 2RHZE/4HR weighing >65kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/4HR weighing >65kg\n TB patients given 2RHZE/4HR weighing >65kg\n \n 2024-02-28 11:08:27 UTC\n \n 2024-02-28 11:11: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 2684\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 16:38:27',4,'2024-02-28 16:41:07',4,0,NULL,NULL,NULL,'70b78a75-3be5-4dc5-a191-21ce2d9621ee'),(2685,'TB patients given 2HRE/10HR weighing < 2kg','TB patients given 2HRE/10HR weighing < 2kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing < 2kg\n TB patients given 2HRE/10HR weighing < 2kg\n \n 2024-02-28 13:08:41 UTC\n \n 2024-02-28 13:14: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 2685\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:38:41',4,'2024-02-28 18:44:55',4,0,NULL,NULL,NULL,'e8ffcdff-a39c-463b-8da6-a622ef5cefaf'),(2686,'TB patients given 2HRE/10HR weighing 2-2.9kg','TB patients given 2HRE/10HR weighing 2-2.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 2-2.9kg\n TB patients given 2HRE/10HR weighing 2-2.9kg\n \n 2024-02-28 13:09:10 UTC\n \n 2024-02-28 13:15: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 2686\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:39:10',4,'2024-02-28 18:45:22',4,0,NULL,NULL,NULL,'fd54220d-0eea-4c40-91d3-6842888ba3b5'),(2687,'TB patients given 2HRE/10HR weighing 3-3.9kg','TB patients given 2HRE/10HR weighing 3-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 3-3.9kg\n TB patients given 2HRE/10HR weighing 3-3.9kg\n \n 2024-02-28 13:09:39 UTC\n \n 2024-02-28 13:16: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 2687\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:39:39',4,'2024-02-28 18:46:19',4,0,NULL,NULL,NULL,'be84889c-0395-437b-9400-c2a7e8eb2ccf'),(2688,'TB patients given 2HRE/10HR weighing 4-7.9kg','TB patients given 2HRE/10HR weighing 4-7.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 4-7.9kg\n TB patients given 2HRE/10HR weighing 4-7.9kg\n \n 2024-02-28 13:10:10 UTC\n \n 2024-02-28 13: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 2688\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:40:10',4,'2024-02-28 18:46:40',4,0,NULL,NULL,NULL,'a204e666-8840-4614-bf83-af7330f68aaa'),(2689,'TB patients given 2HRE/10HR weighing 8-11.9kg','TB patients given 2HRE/10HR weighing 8-11.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 8-11.9kg\n TB patients given 2HRE/10HR weighing 8-11.9kg\n \n 2024-02-28 13:17:57 UTC\n \n 2024-02-28 13: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 2689\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:47:57',4,'2024-02-28 18:53:09',4,0,NULL,NULL,NULL,'139114c2-da7a-4749-89b4-e99e72994d81'),(2690,'TB patients given 2HRE/10HR weighing 12-15.9kg','TB patients given 2HRE/10HR weighing 12-15.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 12-15.9kg\n TB patients given 2HRE/10HR weighing 12-15.9kg\n \n 2024-02-28 13:19:00 UTC\n \n 2024-02-28 13:23: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 2690\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:49:00',4,'2024-02-28 18:53:27',4,0,NULL,NULL,NULL,'346da8a7-01a5-4c66-b438-15b66599e85d'),(2691,'TB patients given 2HRE/10HR weighing 16-24.9kg','TB patients given 2HRE/10HR weighing 16-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 16-24.9kg\n TB patients given 2HRE/10HR weighing 16-24.9kg\n \n 2024-02-28 13:19:33 UTC\n \n 2024-02-28 13:23: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 2691\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:49:33',4,'2024-02-28 18:53:55',4,0,NULL,NULL,NULL,'697a3eab-7fc5-4656-b90c-c8f503ba104e'),(2692,'TB patients given 2HRE/10HR weighing 25-<30kg','TB patients given 2HRE/10HR weighing 25-<30kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 25-<30kg\n TB patients given 2HRE/10HR weighing 25-<30kg\n \n 2024-02-28 13:20:00 UTC\n \n 2024-02-28 13: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 2692\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:50:00',4,'2024-02-28 18:54:21',4,0,NULL,NULL,NULL,'9aaeb85e-bf5b-4cfd-ac28-53cdb1bd4675'),(2693,'TB patients given 2HRE/10HR weighing 30-<35kg','TB patients given 2HRE/10HR weighing 30-<35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 30-<35kg\n TB patients given 2HRE/10HR weighing 30-<35kg\n \n 2024-02-28 13:26:24 UTC\n \n 2024-02-28 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 2693\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:56:24',4,'2024-02-28 19:00:36',4,0,NULL,NULL,NULL,'614b47d9-f71d-43f7-9f20-348a7341b425'),(2694,'TB patients given 2HRE/10HR weighing 35-<50kg','TB patients given 2HRE/10HR weighing 35-<50kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 35-<50kg\n TB patients given 2HRE/10HR weighing 35-<50kg\n \n 2024-02-28 13:27:03 UTC\n \n 2024-02-28 13:30: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 2694\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:57:03',4,'2024-02-28 19:00:58',4,0,NULL,NULL,NULL,'90a894c8-2f13-45b8-a9ff-718cc0b5d958'),(2695,'TB patients given 2HRE/10HR weighing 50-<65kg','TB patients given 2HRE/10HR weighing 50-<65kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing 50-<65kg\n TB patients given 2HRE/10HR weighing 50-<65kg\n \n 2024-02-28 13:27:34 UTC\n \n 2024-02-28 13:31: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 2695\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:57:34',4,'2024-02-28 19:01:21',4,0,NULL,NULL,NULL,'310e9e3a-ae90-4d16-b876-81d55f05e601'),(2696,'TB patients given 2HRE/10HR weighing > 65kg','TB patients given 2HRE/10HR weighing > 65kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2HRE/10HR weighing > 65kg\n TB patients given 2HRE/10HR weighing > 65kg\n \n 2024-02-28 13:28:06 UTC\n \n 2024-02-28 13:31: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 2696\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 18:58:06',4,'2024-02-28 19:01:54',4,0,NULL,NULL,NULL,'fb06b275-034c-492c-bb27-10bef23fce0d'),(2697,'TB patients given 2RHZE/2HR weighing 2-2.9kg','TB patients given 2RHZE/2HR weighing 2-2.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 2-2.9kg\n TB patients given 2RHZE/2HR weighing 2-2.9kg\n \n 2024-02-28 13:38:38 UTC\n \n 2024-02-28 13:43: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 2697\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:08:38',4,'2024-02-28 19:13:00',4,0,NULL,NULL,NULL,'d5432933-9558-4f54-8f6e-abc5e9a0223b'),(2698,'TB patients given 2RHZE/2HR weighing 3-3.9kg','TB patients given 2RHZE/2HR weighing 3-3.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 3-3.9kg\n TB patients given 2RHZE/2HR weighing 3-3.9kg\n \n 2024-02-28 13:39:06 UTC\n \n 2024-02-28 13:48: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 2698\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:09:06',4,'2024-02-28 19:18:32',4,0,NULL,NULL,NULL,'9379b271-3680-47a4-a2be-8145d4e58fa0'),(2699,'TB patients given 2RHZE/2HR weighing 4-7.9kg','TB patients given 2RHZE/2HR weighing 4-7.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 4-7.9kg\n TB patients given 2RHZE/2HR weighing 4-7.9kg\n \n 2024-02-28 13:40:21 UTC\n \n 2024-02-28 13:48: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 2699\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:10:21',4,'2024-02-28 19:18:54',4,0,NULL,NULL,NULL,'c0729714-b7a1-4c39-b44a-dd01fcb1aecc'),(2700,'TB patients given 2RHZE/2HR weighing 8-11.9kg','TB patients given 2RHZE/2HR weighing 8-11.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 8-11.9kg\n TB patients given 2RHZE/2HR weighing 8-11.9kg\n \n 2024-02-28 13:42:30 UTC\n \n 2024-02-28 13:51: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 2700\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:12:30',4,'2024-02-28 19:21:42',4,0,NULL,NULL,NULL,'17375042-6d27-4096-a84b-bbe596fd7580'),(2701,'TB patients given 2RHZE/2HR weighing 12-15.9kg','TB patients given 2RHZE/2HR weighing 12-15.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 12-15.9kg\n TB patients given 2RHZE/2HR weighing 12-15.9kg\n \n 2024-02-28 14:06:02 UTC\n \n 2024-02-28 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 2701\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:36:02',4,'2024-02-28 19:44:26',4,0,NULL,NULL,NULL,'57ab8f00-8036-404f-9365-a541b14bca39'),(2702,'TB patients given 2RHZE/2HR weighing 16-24.9kg','TB patients given 2RHZE/2HR weighing 16-24.9kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 16-24.9kg\n TB patients given 2RHZE/2HR weighing 16-24.9kg\n \n 2024-02-28 14:07:12 UTC\n \n 2024-02-28 14:14: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 2702\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:37:12',4,'2024-02-28 19:44:09',4,0,NULL,NULL,NULL,'385c3355-f68b-4e23-9658-503b7056e688'),(2703,'TB patients given 2RHZE/2HR weighing 25-<30kg','TB patients given 2RHZE/2HR weighing 25-<30kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 25-<30kg\n TB patients given 2RHZE/2HR weighing 25-<30kg\n \n 2024-02-28 14:08:18 UTC\n \n 2024-02-28 14:13: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 2703\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:38:18',4,'2024-02-28 19:43:50',4,0,NULL,NULL,NULL,'ee38e990-b599-423f-8a88-51ab26f92f1c'),(2704,'TB patients given 2RHZE/2HR weighing < 2kg','TB patients given 2RHZE/2HR weighing < 2kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing < 2kg\n TB patients given 2RHZE/2HR weighing < 2kg\n \n 2024-02-28 14:10:05 UTC\n \n 2024-02-28 14:13: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 2704\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:40:05',4,'2024-02-28 19:43:31',4,0,NULL,NULL,NULL,'316b34a7-3579-4f2a-9c1e-59ab23cc0188'),(2705,'TB patients given 2RHZE/2HR weighing 30-<35kg','TB patients given 2RHZE/2HR weighing 30-<35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 30-<35kg\n TB patients given 2RHZE/2HR weighing 30-<35kg\n \n 2024-02-28 14:15:59 UTC\n \n COUNT\n','2024-02-28 19:45:59',4,NULL,NULL,0,NULL,NULL,NULL,'979c7335-0622-4f85-a7cf-2b64b47c7cbf'),(2706,'TB patients given 2RHZE/2HR weighing 30-<35kg','TB patients given 2RHZE/2HR weighing 30-<35kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 30-<35kg\n TB patients given 2RHZE/2HR weighing 30-<35kg\n \n 2024-02-28 14:15:59 UTC\n \n 2024-02-28 14:19: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 2706\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:45:59',4,'2024-02-28 19:49:57',4,0,NULL,NULL,NULL,'db9dc079-bbf6-42dc-958e-c7c002c4e97c'),(2707,'TB patients given 2RHZE/2HR weighing 35-<50kg','TB patients given 2RHZE/2HR weighing 35-<50kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 35-<50kg\n TB patients given 2RHZE/2HR weighing 35-<50kg\n \n 2024-02-28 14:16:32 UTC\n \n 2024-02-28 14: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 2707\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:46:32',4,'2024-02-28 19:49:49',4,0,NULL,NULL,NULL,'cb160b1b-14c9-4b6d-b4f5-b0287f0ee584'),(2708,'TB patients given 2RHZE/2HR weighing 50-<65kg','TB patients given 2RHZE/2HR weighing 50-<65kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing 50-<65kg\n TB patients given 2RHZE/2HR weighing 50-<65kg\n \n 2024-02-28 14:17:00 UTC\n \n 2024-02-28 14:21: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 2708\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:47:00',4,'2024-02-28 19:51:28',4,0,NULL,NULL,NULL,'a605a26b-e6b2-4e39-8568-adea9afbe93c'),(2709,'TB patients given 2RHZE/2HR weighing >65kg','TB patients given 2RHZE/2HR weighing >65kg','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients given 2RHZE/2HR weighing >65kg\n TB patients given 2RHZE/2HR weighing >65kg\n \n 2024-02-28 14:17:28 UTC\n \n 2024-02-28 14: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 2709\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-28 19:47:28',4,'2024-02-28 19:51:11',4,0,NULL,NULL,NULL,'79f70c54-0a3f-456a-bd82-f97868b651e3'),(2710,'TB Case Registration - Block 5','TB Case Registration - Block 5','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Case Registration - Block 5\n TB Case Registration - Block 5\n \n 2024-02-28 14:24:40 UTC\n \n 2024-02-28 14:25: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 2710\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','2024-02-28 19:54:40',4,'2024-02-28 19:55:12',4,0,NULL,NULL,NULL,'2043afe9-3ece-4901-a898-69be11ff0ac5'),(2711,'TB Case Registration - Block 5 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 Case Registration - Block 5 Data Set\n \n 2024-02-28 14:25:12 UTC\n \n 2024-02-29 09:52: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 2711\n \n \n \n 2HPMZ_40-5\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 2HPMZ_50-6\n \n \n \n \n \n \n \n \n \n 2HPMZ_65\n \n \n \n \n \n \n \n \n \n 2HRE/10H12\n \n \n \n \n \n \n \n \n \n 2HRE/10H16\n \n \n \n \n \n \n \n \n \n 2HRE/10H2-\n \n \n \n \n \n \n \n \n \n 2HRE/10H25\n \n \n \n \n \n \n \n \n \n 2HRE/10H3-\n \n \n \n \n \n \n \n \n \n 2HRE/10H30\n \n \n \n \n \n \n \n \n \n 2HRE/10H35\n \n \n \n \n \n \n \n \n \n 2HRE/10H4-\n \n \n \n \n \n \n \n \n \n 2HRE/10H50\n \n \n \n \n \n \n \n \n \n 2HRE/10H65\n \n \n \n \n \n \n \n \n \n 2HRE/10H8-\n \n \n \n \n \n \n \n \n \n 2HRE/10H<2\n \n \n \n \n \n \n \n \n \n 2RHZE/2H12\n \n \n \n \n \n \n \n \n \n 2RHZE/2H16\n \n \n \n \n \n \n \n \n \n 2RHZE/2H2-\n \n \n \n \n \n \n \n \n \n 2RHZE/2H25\n \n \n \n \n \n \n \n \n \n 2RHZE/2H3-\n \n \n \n \n \n \n \n \n \n 2RHZE/2H30\n \n \n \n \n \n \n \n \n \n 2RHZE/2H35\n \n \n \n \n \n \n \n \n \n 2RHZE/2H4-\n \n \n \n \n \n \n \n \n \n 2RHZE/2H50\n \n \n \n \n \n \n \n \n \n 2RHZE/2H65\n \n \n \n \n \n \n \n \n \n 2RHZE/2H8-\n \n \n \n \n \n \n \n \n \n 2RHZE/2H<2\n \n \n \n \n \n \n \n \n \n 2RHZE/4H12\n \n \n \n \n \n \n \n \n \n 2RHZE/4H16\n \n \n \n \n \n \n \n \n \n 2RHZE/4H2-\n \n \n \n \n \n \n \n \n \n 2RHZE/4H25\n \n \n \n \n \n \n \n \n \n 2RHZE/4H3-\n \n \n \n \n \n \n \n \n \n 2RHZE/4H30\n \n \n \n \n \n \n \n \n \n 2RHZE/4H35\n \n \n \n \n \n \n \n \n \n 2RHZE/4H4-\n \n \n \n \n \n \n \n \n \n 2RHZE/4H50\n \n \n \n \n \n \n \n \n \n 2RHZE/4H65\n \n \n \n \n \n \n \n \n \n 2RHZE/4H8-\n \n \n \n \n \n \n \n \n \n 2RHZE/4H<2\n \n \n \n \n \n \n \n \n \n 2RHZE/4R30\n \n \n \n \n \n \n \n \n \n 2RHZE/4R40\n \n \n \n \n \n \n \n \n \n 2RHZE/4R55\n \n \n \n \n \n \n \n \n \n 2RHZE/4R70\n \n \n \n \n \n \n \n \n \n','2024-02-28 19:55:12',4,'2024-02-29 15:22:37',4,0,NULL,NULL,NULL,'8be20f45-e610-469e-b1ba-5b16a08a151f'),(2712,'TB patients diagnosed with GeneXpert - sputum','TB patients diagnosed with GeneXpert - sputum','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with GeneXpert - sputum\n TB patients diagnosed with GeneXpert - sputum\n \n 2024-02-29 13:40:42 UTC\n \n 2024-02-29 13:41: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 2712\n select diagnosis.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_diagnosis \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 3814 and o.value_coded = 3824 -- GeneXpert Sputum \n 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 group by person_id)diagnosis \n\n','2024-02-29 19:10:42',4,'2024-02-29 19:11:05',4,0,NULL,NULL,NULL,'d8a123a8-d4f2-454d-be8b-bb9ccd11c979'),(2713,'TB patients diagnosed with LPA','TB patients diagnosed with LPA','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with LPA\n TB patients diagnosed with LPA\n \n 2024-02-29 13:42:00 UTC\n \n 2024-02-29 13: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 2713\n select diagnosis.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_diagnosis \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 3814 and o.value_coded = 3825 -- LPA \n 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 group by person_id)diagnosis\n','2024-02-29 19:12:00',4,'2024-02-29 19:12:37',4,0,NULL,NULL,NULL,'dbc7ab7e-b251-43e3-b9fc-78250f1dc6d2'),(2714,'TB patients diagnosed with smear microscopy','TB patients diagnosed with smear microscopy','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with smear microscopy\n TB patients diagnosed with smear microscopy\n \n 2024-02-29 13:47:25 UTC\n \n 2024-02-29 13:48: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 2714\n select diagnosis.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_diagnosis \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 3815 and o.value_coded = 3819 -- Smear microscopy \n 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 group by person_id)diagnosis\n','2024-02-29 19:17:25',4,'2024-02-29 19:18:20',4,0,NULL,NULL,NULL,'86c13563-ee30-4fbe-9ee2-3ba5baa43b99'),(2715,'TB patients diagnosed with Culture','TB patients diagnosed with Culture','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with Culture\n TB patients diagnosed with Culture\n \n 2024-02-29 13:50:16 UTC\n \n 2024-02-29 13:50: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 2715\n select diagnosis.Id \nfrom \n(select distinct o.person_id as Id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS TB_diagnosis \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 3815 and o.value_coded = 3819 -- Smear microscopy \n 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 group by person_id)diagnosis\n','2024-02-29 19:20:16',4,'2024-02-29 19:20:55',4,0,NULL,NULL,NULL,'bb273381-7ea5-4c12-83fd-5f6e7e10e853'),(2716,'TB patients diagnosed with Culture','TB patients diagnosed with Culture','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with Culture\n TB patients diagnosed with Culture\n \n 2024-02-29 14:01:00 UTC\n \n 2024-02-29 14:06: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 2716\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-29 19:31:00',4,'2024-02-29 19:36:16',4,0,NULL,NULL,NULL,'b9218e8a-e0af-48a8-8107-dcc9a9a7a066'),(2717,'TB patients diagnosed with GeneXpert - sputum','TB patients diagnosed with GeneXpert - sputum','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with GeneXpert - sputum\n TB patients diagnosed with GeneXpert - sputum\n \n 2024-02-29 14:10:38 UTC\n \n COUNT\n','2024-02-29 19:40:38',4,NULL,NULL,0,NULL,NULL,NULL,'3a5d9a42-ab26-4205-b5a2-f2f53ea6c5bc'),(2718,'TB patients diagnosed with GeneXpert - sputum','TB patients diagnosed with GeneXpert - sputum','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with GeneXpert - sputum\n TB patients diagnosed with GeneXpert - sputum\n \n 2024-02-29 14:10:40 UTC\n \n 2024-02-29 14:35: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 2718\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-29 19:40:40',4,'2024-02-29 20:05:27',4,0,NULL,NULL,NULL,'a9c92543-222b-490d-bfa3-d2bcb6825eec'),(2719,'TB patients diagnosed with LPA','TB patients diagnosed with LPA','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with LPA\n TB patients diagnosed with LPA\n \n 2024-02-29 14:36:14 UTC\n \n 2024-02-29 14: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 2719\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-29 20:06:14',4,'2024-02-29 20:08:26',4,0,NULL,NULL,NULL,'7b6eb2f0-56a4-4c91-81c2-1e4abb4e98d2'),(2720,'TB patients diagnosed with smear microscopy','TB patients diagnosed with smear microscopy','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB patients diagnosed with smear microscopy\n TB patients diagnosed with smear microscopy\n \n 2024-02-29 14:37:25 UTC\n \n 2024-02-29 14:39: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 2720\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-02-29 20:07:25',4,'2024-02-29 20:09:11',4,0,NULL,NULL,NULL,'a27eacbd-b0a6-446f-950f-0402e720c4bb'),(2721,'TB Case Registration - Block 6','TB Case Registration - Block 6','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Case Registration - Block 6\n TB Case Registration - Block 6\n \n 2024-02-29 14:51:54 UTC\n \n 2024-02-29 14:52: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 2721\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','2024-02-29 20:21:54',4,'2024-02-29 20:22:47',4,0,NULL,NULL,NULL,'aeb7f90e-d61b-49b3-ae0f-6940f6d50c47'),(2724,'TB Case Registration - Block 6 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 Case Registration - Block 6 Data Set\n \n 2024-02-29 14:52:47 UTC\n \n 2024-02-29 15:07: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 2724\n \n \n \n Culture\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 GeneX_sput\n \n \n \n \n \n \n \n \n \n LPA\n \n \n \n \n \n \n \n \n \n Smear_micr\n \n \n \n \n \n \n \n \n \n','2024-02-29 20:22:47',4,'2024-02-29 20:37:45',4,0,NULL,NULL,NULL,'7db12160-92c5-4680-8972-988b5bdd2157'),(2725,'TB Case Registration - Block 6 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 Case Registration - Block 6 Data Set\n \n 2024-02-29 14:54: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 \n \n','2024-02-29 20:24:55',4,NULL,NULL,0,NULL,NULL,NULL,'dcdae370-ec79-44e6-9231-e5ab06942acf'),(2726,'TB Case Registration - Block 6 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 Case Registration - Block 6 Data Set\n \n 2024-02-29 14:55: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 \n \n','2024-02-29 20:25:05',4,NULL,NULL,0,NULL,NULL,NULL,'0613568a-14f8-488c-9721-431f1ab21e93'),(2727,'test - TAT','Test - TAT','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n test - TAT\n Test - TAT\n \n 2024-05-06 09:16:29 UTC\n \n 2024-05-06 10:36: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 2727\n select lab_orders.order_id \nfrom \n(select order_id, encounter_id, date_created \nfrom orders \nwhere concept_id = 5484 \nand voided = 0 \nand cast(date_created as date ) >= cast(:startDate as date) \nand cast(date_created as date ) <= cast(:endDate as date) \n)lab_orders \n \ninner join \n \n(Select result.order_id, Results, cast(obs_datetime as date) as result_date \n From \n ( \n select oss.person_id as pId, concat(oss.value_numeric, " ", "copies/ml") as Results, order_id, oss.obs_datetime \n from obs oss \n where oss.concept_id = 5485 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast(:startDate as date) \n group by oss.person_id \n \n UNION \n \n select oss.person_id as pId, "LDL" as Results, order_id, oss.obs_datetime \n from obs oss \n where oss.concept_id = 5489 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast(:startDate as date) \n group by oss.person_id \n \n )result \n )VL_result \n on VL_result.order_id = lab_orders.order_id \n \n\n','2024-05-06 14:46:29',4,'2024-05-06 16:06:56',4,0,NULL,NULL,NULL,'aba10bbe-5770-4127-b7b9-50826cffd0a5'),(2728,'ART clients given MMD - 2 months','ART clients who were prescribed 2 months Multi-Month Drugs','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients given MMD - 2 months\n ART clients who were prescribed 2 months Multi-Month Drugs\n \n 2024-05-14 12:27:28 UTC\n \n 2024-05-14 14:11: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 2728\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 \n(SELECT Id \nFROM ( \n \n (SELECT Id, patientIdentifier , patientName, Age, Gender, age_group, 'Seen_Previous' AS 'Program_Status', sort_order \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 -- Clients with a followup visit in the future and taken from their latest followup form \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 and voided = 0 \n and A.observation_id = B.obs_group_id \n and B.voided = 0 \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 -- Clients seen this month \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 -- Clients initiated this month \n select distinct os.person_id \n from obs os \n where concept_id = 2249 and os.voided =0 \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 and os.voided = 0 \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 -- Died \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n \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)AS Seen_Prev \n \ninner join \n \n(select B.person_id as person_id, B.obs_group_id, max_observation \n from obs B \n inner join \n (select person_id, Max(CAST(obs_datetime AS DATE)) as max_observation, 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 = 4174 and value_coded = 4176 \n and A.observation_id = B.obs_group_id \n and B.voided = 0 \n)drug_duration \non drug_duration.person_id = Seen_Prev.Id \n)\n','2024-05-14 17:57:28',4,'2024-05-14 19:41:45',4,0,NULL,NULL,NULL,'0f57ce0c-d729-4789-9217-813cd76869c1'),(2729,'ART clients given MMD - 3 months','ART clients who were prescribed 3 months Multi-Month Drugs','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients given MMD - 3 months\n ART clients who were prescribed 3 months Multi-Month Drugs\n \n 2024-05-14 14:14:35 UTC\n \n 2024-05-14 14:20: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 2729\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 \n(SELECT Id \nFROM ( \n \n (SELECT Id, patientIdentifier , patientName, Age, Gender, age_group, 'Seen_Previous' AS 'Program_Status', sort_order \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 -- Clients with a followup visit in the future and taken from their latest followup form \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 and voided = 0 \n and A.observation_id = B.obs_group_id \n and B.voided = 0 \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 -- Clients seen this month \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 -- Clients initiated this month \n select distinct os.person_id \n from obs os \n where concept_id = 2249 and os.voided =0 \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 and os.voided = 0 \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 -- Died \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n \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)AS Seen_Prev \n \ninner join \n \n(select B.person_id as person_id, B.obs_group_id, max_observation \n from obs B \n inner join \n (select person_id, Max(CAST(obs_datetime AS DATE)) as max_observation, 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 = 4174 and value_coded = 4177 \n and A.observation_id = B.obs_group_id \n and B.voided = 0 \n)drug_duration \non drug_duration.person_id = Seen_Prev.Id \n)\n','2024-05-14 19:44:35',4,'2024-05-14 19:50:42',4,0,NULL,NULL,NULL,'daeeabcf-a069-4577-bd25-8f6be8d0ad84'),(2730,'ART clients given MMD - 4to5_months','ART clients who were prescribed 4 to 5 months Multi-Month Drugs','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients given MMD - 4to5_months\n ART clients who were prescribed 4 to 5 months Multi-Month Drugs\n \n 2024-05-14 14:16:36 UTC\n \n 2024-05-14 14: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 2730\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 \n(SELECT Id \nFROM ( \n \n (SELECT Id, patientIdentifier , patientName, Age, Gender, age_group, 'Seen_Previous' AS 'Program_Status', sort_order \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 -- Clients with a followup visit in the future and taken from their latest followup form \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 and voided = 0 \n and A.observation_id = B.obs_group_id \n and B.voided = 0 \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 -- Clients seen this month \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 -- Clients initiated this month \n select distinct os.person_id \n from obs os \n where concept_id = 2249 and os.voided =0 \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 and os.voided = 0 \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 -- Died \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n \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)AS Seen_Prev \n \ninner join \n \n(select B.person_id as person_id, B.obs_group_id, max_observation \n from obs B \n inner join \n (select person_id, Max(CAST(obs_datetime AS DATE)) as max_observation, 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 = 4174 and value_coded in (4245,4246) \n and A.observation_id = B.obs_group_id \n and B.voided = 0 \n)drug_duration \non drug_duration.person_id = Seen_Prev.Id \n)\n','2024-05-14 19:46:36',4,'2024-05-14 19:52:44',4,0,NULL,NULL,NULL,'09ce59b7-a690-4e94-954f-0af7536e72dc'),(2731,'ART clients given MMD - 5 months','ART clients who were prescribed 5 months Multi-Month Drugs','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients given MMD - 5 months\n ART clients who were prescribed 5 months Multi-Month Drugs\n \n 2024-05-14 14:18:29 UTC\n \n 2024-05-14 14:21: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 2731\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 \n(SELECT Id \nFROM ( \n \n (SELECT Id, patientIdentifier , patientName, Age, Gender, age_group, 'Seen_Previous' AS 'Program_Status', sort_order \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 -- Clients with a followup visit in the future and taken from their latest followup form \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 and voided = 0 \n and A.observation_id = B.obs_group_id \n and B.voided = 0 \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 -- Clients seen this month \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 -- Clients initiated this month \n select distinct os.person_id \n from obs os \n where concept_id = 2249 and os.voided =0 \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 and os.voided = 0 \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 -- Died \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n \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)AS Seen_Prev \n \ninner join \n \n(select B.person_id as person_id, B.obs_group_id, max_observation \n from obs B \n inner join \n (select person_id, Max(CAST(obs_datetime AS DATE)) as max_observation, 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 = 4174 and value_coded = 4246 \n and A.observation_id = B.obs_group_id \n and B.voided = 0 \n)drug_duration \non drug_duration.person_id = Seen_Prev.Id \n)\n','2024-05-14 19:48:29',4,'2024-05-14 19:51:04',4,0,NULL,NULL,NULL,'469899fc-d216-4fcd-bbdf-39de7b9f3c3c'),(2732,'ART clients given MMD - 6 months','ART clients who were prescribed 6 months Multi-Month Drugs','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients given MMD - 6 months\n ART clients who were prescribed 6 months Multi-Month Drugs\n \n 2024-05-14 14:18:49 UTC\n \n 2024-05-14 14:21: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 2732\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 \n(SELECT Id \nFROM ( \n \n (SELECT Id, patientIdentifier , patientName, Age, Gender, age_group, 'Seen_Previous' AS 'Program_Status', sort_order \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 -- Clients with a followup visit in the future and taken from their latest followup form \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 and voided = 0 \n and A.observation_id = B.obs_group_id \n and B.voided = 0 \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 -- Clients seen this month \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 -- Clients initiated this month \n select distinct os.person_id \n from obs os \n where concept_id = 2249 and os.voided =0 \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 and os.voided = 0 \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 -- Died \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n \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)AS Seen_Prev \n \ninner join \n \n(select B.person_id as person_id, B.obs_group_id, max_observation \n from obs B \n inner join \n (select person_id, Max(CAST(obs_datetime AS DATE)) as max_observation, 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 = 4174 and value_coded = 4247 \n and A.observation_id = B.obs_group_id \n and B.voided = 0 \n)drug_duration \non drug_duration.person_id = Seen_Prev.Id \n)\n','2024-05-14 19:48:49',4,'2024-05-14 19:51:14',4,0,NULL,NULL,NULL,'87a4fa92-18da-4157-8a25-9380d339b8c0'),(2733,'ART clients given MMD - 7+ months','ART clients who were prescribed 7+ months Multi-Month Drugs','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients given MMD - 7+ months\n ART clients who were prescribed 7+ months Multi-Month Drugs\n \n 2024-05-14 14:19:03 UTC\n \n 2024-05-14 14:21: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 2733\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 \n(SELECT Id \nFROM ( \n \n (SELECT Id, patientIdentifier , patientName, Age, Gender, age_group, 'Seen_Previous' AS 'Program_Status', sort_order \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 -- Clients with a followup visit in the future and taken from their latest followup form \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 and voided = 0 \n and A.observation_id = B.obs_group_id \n and B.voided = 0 \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 -- Clients seen this month \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 -- Clients initiated this month \n select distinct os.person_id \n from obs os \n where concept_id = 2249 and os.voided =0 \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 and os.voided = 0 \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 -- Died \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \n \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)AS Seen_Prev \n \ninner join \n \n(select B.person_id as person_id, B.obs_group_id, max_observation \n from obs B \n inner join \n (select person_id, Max(CAST(obs_datetime AS DATE)) as max_observation, 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 = 4174 and value_coded = 4820 \n and A.observation_id = B.obs_group_id \n and B.voided = 0 \n)drug_duration \non drug_duration.person_id = Seen_Prev.Id \n)\n','2024-05-14 19:49:03',4,'2024-05-14 19:51:26',4,0,NULL,NULL,NULL,'5632575c-ac44-4b23-b994-c881df258fc0'),(2734,'HIV Care and Treatment 2024 Block 2','ART CARE: NEW AND CURRENT NUMBER OF PEOPLE ON ART','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HIV Care and Treatment 2024 Block 2\n ART CARE: NEW AND CURRENT NUMBER OF PEOPLE ON ART\n \n 2024-05-15 11:10:21 UTC\n \n 2024-05-15 11:11: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 2734\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','2024-05-15 16:40:21',4,'2024-05-15 16:41:17',4,0,NULL,NULL,NULL,'e265fabc-f2c6-4f53-9e32-0f7daee2206f'),(2736,'HIV Care and Treatment 2024 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 HIV Care and Treatment 2024 Block 2 Data Set\n \n 2024-05-15 11:11:17 UTC\n \n 2024-05-20 10:33: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 2736\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n DiedClient\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 LostToFU\n \n \n \n \n \n \n \n \n \n MMD2mF1-4\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n MMD2mF10-1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n MMD2mF15-1\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n MMD2mF20-2\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n MMD2mF25-2\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n MMD2mF30-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n MMD2mF35-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n MMD2mF40-4\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n MMD2mF45-4\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n MMD2mF5-9\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n MMD2mF50\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n MMD2mF<1yr\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n MMD2mM1-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 01-04yrs\n \n \n \n \n \n MMD2mM10-1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 10-14yrs\n \n \n \n \n \n MMD2mM15-1\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 15-19yrs\n \n \n \n \n \n MMD2mM20-2\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 20-24yrs\n \n \n \n \n \n MMD2mM25-2\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 25-29yrs\n \n \n \n \n \n MMD2mM30-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 30-34yrs\n \n \n \n \n \n MMD2mM35-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 35-39yrs\n \n \n \n \n \n MMD2mM40-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 40-44yrs\n \n \n \n \n \n MMD2mM45-4\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 45-49yrs\n \n \n \n \n \n MMD2mM5-9\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 05-09yrs\n \n \n \n \n \n MMD2mM50\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n 50Plus\n \n \n \n \n \n MMD2mM<1yr\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Finer_Age\n Under1yr\n \n \n \n \n \n MMD3mF1-4\n \n \n \n \n \n \n \n \n \n MMD3mF10-1\n \n \n \n \n \n \n MMD3mF15-1\n \n \n \n \n \n \n MMD3mF20-2\n \n \n \n \n \n \n MMD3mF25-2\n \n \n \n \n \n \n MMD3mF30-3\n \n \n \n \n \n \n MMD3mF35-3\n \n \n \n \n \n \n MMD3mF40-4\n \n \n \n \n \n \n MMD3mF45-4\n \n \n \n \n \n \n MMD3mF5-9\n \n \n \n \n \n \n MMD3mF50\n \n \n \n \n \n \n MMD3mF<1yr\n \n \n \n \n \n \n MMD3mM1-4\n \n \n \n \n \n \n MMD3mM10-1\n \n \n \n \n \n \n MMD3mM15-1\n \n \n \n \n \n \n MMD3mM20-2\n \n \n \n \n \n \n MMD3mM25-2\n \n \n \n \n \n \n MMD3mM30-3\n \n \n \n \n \n \n MMD3mM35-3\n \n \n \n \n \n \n MMD3mM40-4\n \n \n \n \n \n \n MMD3mM45-4\n \n \n \n \n \n \n MMD3mM5-9\n \n \n \n \n \n \n MMD3mM50\n \n \n \n \n \n \n MMD3mM<1yr\n \n \n \n \n \n \n MMD4-5mF1-\n \n \n \n \n \n \n \n \n \n MMD4-5mF10\n \n \n \n \n \n \n MMD4-5mF15\n \n \n \n \n \n \n MMD4-5mF20\n \n \n \n \n \n \n MMD4-5mF25\n \n \n \n \n \n \n MMD4-5mF30\n \n \n \n \n \n \n MMD4-5mF35\n \n \n \n \n \n \n MMD4-5mF40\n \n \n \n \n \n \n MMD4-5mF45\n \n \n \n \n \n \n MMD4-5mF5-\n \n \n \n \n \n \n MMD4-5mF50\n \n \n \n \n \n \n MMD4-5mF<1\n \n \n \n \n \n \n MMD4-5mM1-\n \n \n \n \n \n \n MMD4-5mM10\n \n \n \n \n \n \n MMD4-5mM15\n \n \n \n \n \n \n MMD4-5mM20\n \n \n \n \n \n \n MMD4-5mM25\n \n \n \n \n \n \n MMD4-5mM30\n \n \n \n \n \n \n MMD4-5mM35\n \n \n \n \n \n \n MMD4-5mM40\n \n \n \n \n \n \n MMD4-5mM45\n \n \n \n \n \n \n MMD4-5mM5-\n \n \n \n \n \n \n MMD4-5mM50\n \n \n \n \n \n \n MMD4-5mM<1\n \n \n \n \n \n \n MMD6mF1-4\n \n \n \n \n \n \n \n \n \n MMD6mF10-1\n \n \n \n \n \n \n MMD6mF15-1\n \n \n \n \n \n \n MMD6mF20-2\n \n \n \n \n \n \n MMD6mF25-2\n \n \n \n \n \n \n MMD6mF30-3\n \n \n \n \n \n \n MMD6mF35-3\n \n \n \n \n \n \n MMD6mF40-4\n \n \n \n \n \n \n MMD6mF45-4\n \n \n \n \n \n \n MMD6mF5-9\n \n \n \n \n \n \n MMD6mF50\n \n \n \n \n \n \n MMD6mF<1yr\n \n \n \n \n \n \n MMD6mM1-4\n \n \n \n \n \n \n MMD6mM10-1\n \n \n \n \n \n \n MMD6mM15-1\n \n \n \n \n \n \n MMD6mM20-2\n \n \n \n \n \n \n MMD6mM25-2\n \n \n \n \n \n \n MMD6mM30-3\n \n \n \n \n \n \n MMD6mM35-3\n \n \n \n \n \n \n MMD6mM40-4\n \n \n \n \n \n \n MMD6mM45-4\n \n \n \n \n \n \n MMD6mM5-9\n \n \n \n \n \n \n MMD6mM50\n \n \n \n \n \n \n MMD6mM<1yr\n \n \n \n \n \n \n MMD7mF1-4\n \n \n \n \n \n \n \n \n \n MMD7mF10-1\n \n \n \n \n \n \n MMD7mF15-1\n \n \n \n \n \n \n MMD7mF20-2\n \n \n \n \n \n \n MMD7mF25-2\n \n \n \n \n \n \n MMD7mF30-3\n \n \n \n \n \n \n MMD7mF35-3\n \n \n \n \n \n \n MMD7mF40-4\n \n \n \n \n \n \n MMD7mF45-4\n \n \n \n \n \n \n MMD7mF5-9\n \n \n \n \n \n \n MMD7mF50\n \n \n \n \n \n \n MMD7mF<1yr\n \n \n \n \n \n \n MMD7mM1-4\n \n \n \n \n \n \n MMD7mM10-1\n \n \n \n \n \n \n MMD7mM15-1\n \n \n \n \n \n \n MMD7mM20-2\n \n \n \n \n \n \n MMD7mM25-2\n \n \n \n \n \n \n MMD7mM30-3\n \n \n \n \n \n \n MMD7mM35-3\n \n \n \n \n \n \n MMD7mM40-4\n \n \n \n \n \n \n MMD7mM45-4\n \n \n \n \n \n \n MMD7mM5-9\n \n \n \n \n \n \n MMD7mM50\n \n \n \n \n \n \n MMD7mM<1yr\n \n \n \n \n \n \n MissedF1-4\n \n \n \n \n \n \n \n \n \n MissedF10-\n \n \n \n \n \n \n MissedF15-\n \n \n \n \n \n \n MissedF20-\n \n \n \n \n \n \n MissedF25-\n \n \n \n \n \n \n MissedF30-\n \n \n \n \n \n \n MissedF35-\n \n \n \n \n \n \n MissedF40-\n \n \n \n \n \n \n MissedF45-\n \n \n \n \n \n \n MissedF5-9\n \n \n \n \n \n \n MissedF50\n \n \n \n \n \n \n MissedF<1y\n \n \n \n \n \n \n MissedM1-4\n \n \n \n \n \n \n MissedM10-\n \n \n \n \n \n \n MissedM15-\n \n \n \n \n \n \n MissedM20-\n \n \n \n \n \n \n MissedM25-\n \n \n \n \n \n \n MissedM30-\n \n \n \n \n \n \n MissedM35-\n \n \n \n \n \n \n MissedM40-\n \n \n \n \n \n \n MissedM45-\n \n \n \n \n \n \n MissedM5-9\n \n \n \n \n \n \n MissedM50\n \n \n \n \n \n \n MissedM<1y\n \n \n \n \n \n \n NewF1-4\n \n \n \n \n \n \n \n \n \n NewF10-14\n \n \n \n \n \n \n NewF15-19\n \n \n \n \n \n \n NewF20-24\n \n \n \n \n \n \n NewF25-29\n \n \n \n \n \n \n NewF30-34\n \n \n \n \n \n \n NewF35-39\n \n \n \n \n \n \n NewF40-44\n \n \n \n \n \n \n NewF45-49\n \n \n \n \n \n \n NewF5-9\n \n \n \n \n \n \n NewF50\n \n \n \n \n \n \n NewF<1yr\n \n \n \n \n \n \n NewM1-4\n \n \n \n \n \n \n NewM10-14\n \n \n \n \n \n \n NewM15-19\n \n \n \n \n \n \n NewM20-24\n \n \n \n \n \n \n NewM25-29\n \n \n \n \n \n \n NewM30-34\n \n \n \n \n \n \n NewM35-39\n \n \n \n \n \n \n NewM40-44\n \n \n \n \n \n \n NewM45-49\n \n \n \n \n \n \n NewM5-9\n \n \n \n \n \n \n NewM50\n \n \n \n \n \n \n NewM<1yr\n \n \n \n \n \n \n Restarted\n \n \n \n \n \n \n \n \n \n SeenF1-4\n \n \n \n \n \n \n \n \n \n SeenF10-14\n \n \n \n \n \n \n SeenF15-19\n \n \n \n \n \n \n SeenF20-24\n \n \n \n \n \n \n SeenF25-29\n \n \n \n \n \n \n SeenF30-34\n \n \n \n \n \n \n SeenF35-39\n \n \n \n \n \n \n SeenF40-44\n \n \n \n \n \n \n SeenF45-49\n \n \n \n \n \n \n SeenF5-9\n \n \n \n \n \n \n SeenF50\n \n \n \n \n \n \n SeenF<1yr\n \n \n \n \n \n \n SeenM1-4\n \n \n \n \n \n \n SeenM10-14\n \n \n \n \n \n \n SeenM15-19\n \n \n \n \n \n \n SeenM20-24\n \n \n \n \n \n \n SeenM25-29\n \n \n \n \n \n \n SeenM30-34\n \n \n \n \n \n \n SeenM35-39\n \n \n \n \n \n \n SeenM40-44\n \n \n \n \n \n \n SeenM45-49\n \n \n \n \n \n \n SeenM5-9\n \n \n \n \n \n \n SeenM50\n \n \n \n \n \n \n SeenM<1yr\n \n \n \n \n \n \n StoppedART\n \n \n \n \n \n \n \n \n \n TransferIn\n \n \n \n \n \n \n \n \n \n TransferOu\n \n \n \n \n \n \n \n \n \n','2024-05-15 16:41:17',4,'2024-05-20 16:03:49',4,0,NULL,NULL,NULL,'532522c9-551a-4e5d-8357-8baf5583a828'),(2737,'HIV Care and Treatment 2024 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 HIV Care and Treatment 2024 Block 2 Data Set\n \n 2024-05-15 11:11:24 UTC\n \n 2024-05-15 11:21: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 2737\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Finer_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n','2024-05-15 16:41:24',4,'2024-05-15 16:51:48',4,0,NULL,NULL,NULL,'e2d49e46-71d8-47fc-a924-46985a567ef0'),(2738,'ART clients given MMD - 2 months','ART clients given MMD - 2 months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients given MMD - 2 months\n ART clients given MMD - 2 months\n \n 2024-05-15 11:28:36 UTC\n \n 2024-05-15 11:30: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 2738\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-15 16:58:36',4,'2024-05-15 17:00:01',4,0,NULL,NULL,NULL,'0b3ee057-a113-42a4-b195-adfa138e0466'),(2739,'ART clients given MMD - 3 months','ART clients given MMD - 3 months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients given MMD - 3 months\n ART clients given MMD - 3 months\n \n 2024-05-15 11:30:23 UTC\n \n 2024-05-15 11:32: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 2739\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-15 17:00:23',4,'2024-05-15 17:02:12',4,0,NULL,NULL,NULL,'ac28ee24-bd12-45f5-aae0-41581185af99'),(2740,'ART clients given MMD - 4to5_months','ART clients given MMD - 4to5_months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients given MMD - 4to5_months\n ART clients given MMD - 4to5_months\n \n 2024-05-15 11:30:50 UTC\n \n 2024-05-15 11:32: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 2740\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-15 17:00:50',4,'2024-05-15 17:02:33',4,0,NULL,NULL,NULL,'29a42054-8373-478d-a71e-09dc37ccb71b'),(2741,'ART clients given MMD - 6 months','ART clients given MMD - 6 months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients given MMD - 6 months\n ART clients given MMD - 6 months\n \n 2024-05-15 11:36:08 UTC\n \n 2024-05-15 11:37: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 2741\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-15 17:06:08',4,'2024-05-15 17:07:39',4,0,NULL,NULL,NULL,'a88b2fce-a2c2-4218-b1ee-a0a74d6d73fb'),(2742,'ART clients given MMD - 7+ months','ART clients given MMD - 7+ months','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients given MMD - 7+ months\n ART clients given MMD - 7+ months\n \n 2024-05-15 11:36:33 UTC\n \n 2024-05-15 11:37: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 2742\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-15 17:06:33',4,'2024-05-15 17:07:55',4,0,NULL,NULL,NULL,'6537590d-a8eb-4487-bfed-2f3d72afb826'),(2743,'HIV Care and Treatment 2024 Block 4','ADULT ARV REGIMEN AT THE END OF THE MONTH (15+)','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HIV Care and Treatment 2024 Block 4\n ADULT ARV REGIMEN AT THE END OF THE MONTH (15+)\n \n 2024-05-20 10:57:16 UTC\n \n 2024-05-20 10: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 2743\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','2024-05-20 16:27:16',4,'2024-05-20 16:27:44',4,0,NULL,NULL,NULL,'1fdde812-b388-495e-ac45-ccf84aad6229'),(2744,'HIV Care and Treatment 2024 Block 4 Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HIV Care and Treatment 2024 Block 4 Data Set\n \n 2024-05-20 10:57:44 UTC\n \n 2024-05-21 12:57: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 2744\n \n \n DM_Sex\n \n \n \n \n \n \n \n \n 1cFemales\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 1cMales\n \n \n \n \n DM_Sex\n Males\n \n \n \n \n \n 1dFemales\n \n \n \n \n \n \n \n \n \n 1dMales\n \n \n \n \n \n \n 1eFemales\n \n \n \n \n \n \n \n \n \n 1eMales\n \n \n \n \n \n \n 1fFemales\n \n \n \n \n \n \n \n \n \n 1fMales\n \n \n \n \n \n \n 1gFemales\n \n \n \n \n \n \n \n \n \n 1gMales\n \n \n \n \n \n \n 1hFemales\n \n \n \n \n \n \n \n \n \n 1hMales\n \n \n \n \n \n \n 1jFemales\n \n \n \n \n \n \n \n \n \n 1jMales\n \n \n \n \n \n \n 1kFemales\n \n \n \n \n \n \n \n \n \n 1kMales\n \n \n \n \n \n \n 1mFemales\n \n \n \n \n \n \n \n \n \n 1mMales\n \n \n \n \n \n \n 1nFemales\n \n \n \n \n \n \n \n \n \n 1nMales\n \n \n \n \n \n \n 1pFemales\n \n \n \n \n \n \n \n \n \n 1pMales\n \n \n \n \n \n \n 1qFemales\n \n \n \n \n \n \n \n \n \n 1qMales\n \n \n \n \n \n \n 2cMales\n \n \n \n \n \n \n \n \n \n 2dFemales\n \n \n \n \n \n \n \n \n \n 2dMales\n \n \n \n \n \n \n 2eFemales\n \n \n \n \n \n \n \n \n \n 2eMales\n \n \n \n \n \n \n 2fFemales\n \n \n \n \n \n \n \n \n \n 2fMales\n \n \n \n \n \n \n 2gFemales\n \n \n \n \n \n \n \n \n \n 2gMales\n \n \n \n \n \n \n 2hFemales\n \n \n \n \n \n \n \n \n \n 2hMales\n \n \n \n \n \n \n 2iFemales\n \n \n \n \n \n \n \n \n \n 2iMales\n \n \n \n \n \n \n 2jFemales\n \n \n \n \n \n \n \n \n \n 2jMales\n \n \n \n \n \n \n 2kFemales\n \n \n \n \n \n \n \n \n \n 2kMales\n \n \n \n \n \n \n 2lFemales\n \n \n \n \n \n \n \n \n \n 2lMales\n \n \n \n \n \n \n 2mFemales\n \n \n \n \n \n \n \n \n \n 2mMales\n \n \n \n \n \n \n 2nFemales\n \n \n \n \n \n \n \n \n \n 2nMales\n \n \n \n \n \n \n 2oFemales\n \n \n \n \n \n \n \n \n \n 2oMales\n \n \n \n \n \n \n 2pFemales\n \n \n \n \n \n \n \n \n \n 2pMales\n \n \n \n \n \n \n 2qFemales\n \n \n \n \n \n \n \n \n \n 2qMales\n \n \n \n \n \n \n 2rFemales\n \n \n \n \n \n \n \n \n \n 2rMales\n \n \n \n \n \n \n 2sFemales\n \n \n \n \n \n \n \n \n \n 2sMales\n \n \n \n \n \n \n 3aFemales\n \n \n \n \n \n \n \n \n \n 3aMales\n \n \n \n \n \n \n 3bFemales\n \n \n \n \n \n \n \n \n \n 3bMales\n \n \n \n \n \n \n 3cFemales\n \n \n \n \n \n \n \n \n \n 3cMales\n \n \n \n \n \n \n 3dFemales\n \n \n \n \n \n \n \n \n \n 3dMales\n \n \n \n \n \n \n 3eFemales\n \n \n \n \n \n \n \n \n \n 3eMales\n \n \n \n \n \n \n 3fFemales\n \n \n \n \n \n \n \n \n \n 3fMales\n \n \n \n \n \n \n 3gFemales\n \n \n \n \n \n \n \n \n \n 3gMales\n \n \n \n \n \n \n 3hFemales\n \n \n \n \n \n \n \n \n \n 3hMales\n \n \n \n \n \n \n','2024-05-20 16:27:44',4,'2024-05-21 18:27:14',4,0,NULL,NULL,NULL,'c42ed89c-d18d-48bd-9951-e5572a676f23'),(2745,'Clients active on ART given 1c','Clients active on ART given 1c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1c\n Clients active on ART given 1c\n \n 2024-05-20 13:31:02 UTC\n \n 2024-05-20 13:31: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 2745\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 2201)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:01:02',4,'2024-05-20 19:01:32',4,0,NULL,NULL,NULL,'c8596ba4-8b19-4e13-94f6-857af6835462'),(2746,'Clients active on ART given 1d','Clients active on ART given 1d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1d\n Clients active on ART given 1d\n \n 2024-05-20 13:34:57 UTC\n \n 2024-05-20 13:35: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 2746\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 2203)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:04:57',4,'2024-05-20 19:05:48',4,0,NULL,NULL,NULL,'43044544-290c-4635-a6c3-90c5f65a8507'),(2747,'Clients active on ART given 1e','Clients active on ART given 1e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1e\n Clients active on ART given 1e\n \n 2024-05-20 13:35:18 UTC\n \n 2024-05-20 13: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 2747\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 2205)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:05:18',4,'2024-05-20 19:06:30',4,0,NULL,NULL,NULL,'bbde69b1-b875-4995-8b67-a8f17988d7de'),(2748,'Clients active on ART given 1f','Clients active on ART given 1f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1f\n Clients active on ART given 1f\n \n 2024-05-20 13:38:03 UTC\n \n 2024-05-20 13:43: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 2748\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 2207)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:08:03',4,'2024-05-20 19:13:39',4,0,NULL,NULL,NULL,'050bd3fb-c70b-4e62-8f76-34226f4b9c74'),(2749,'Clients active on ART given 1g','Clients active on ART given 1g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1g\n Clients active on ART given 1g\n \n 2024-05-20 13:38:23 UTC\n \n 2024-05-20 13:44: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 2749\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 3672)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:08:23',4,'2024-05-20 19:14:13',4,0,NULL,NULL,NULL,'de2736b1-1ff8-4334-b4ba-c94bb1621f1a'),(2750,'Clients active on ART given 1h','Clients active on ART given 1h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1h\n Clients active on ART given 1h\n \n 2024-05-20 13:38:45 UTC\n \n 2024-05-20 13:44: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 2750\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 3673)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:08:45',4,'2024-05-20 19:14:38',4,0,NULL,NULL,NULL,'0ec54f3e-dde1-4b5c-aca6-b56c3348614d'),(2751,'Clients active on ART given 1j','Clients active on ART given 1j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1j\n Clients active on ART given 1j\n \n 2024-05-20 13:45:45 UTC\n \n 2024-05-20 13:47: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 2751\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4678)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:15:45',4,'2024-05-20 19:17:40',4,0,NULL,NULL,NULL,'d2769f45-fff0-4245-9153-2b5bcc148199'),(2752,'Clients active on ART given 1k','Clients active on ART given 1k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1k\n Clients active on ART given 1k\n \n 2024-05-20 13:46:10 UTC\n \n 2024-05-20 13:47: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 2752\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4679)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:16:10',4,'2024-05-20 19:17:27',4,0,NULL,NULL,NULL,'51ead597-84d8-4a71-b701-6f9c40e0bd00'); +INSERT INTO `serialized_object` VALUES (2753,'Clients active on ART given 1m','Clients active on ART given 1m','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1m\n Clients active on ART given 1m\n \n 2024-05-20 13:46:31 UTC\n \n 2024-05-20 13:47: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 2753\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4680)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:16:31',4,'2024-05-20 19:17:15',4,0,NULL,NULL,NULL,'38d6102a-670c-4746-89f4-9ef8f7e77be9'),(2754,'Clients active on ART given 1n','Clients active on ART given 1n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1n\n Clients active on ART given 1n\n \n 2024-05-20 13:48:24 UTC\n \n 2024-05-20 13:50: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 2754\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4681)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:18:24',4,'2024-05-20 19:20:06',4,0,NULL,NULL,NULL,'5bd0b2b1-f675-438e-8a43-dfeff7068ebf'),(2755,'Clients active on ART given 1p','Clients active on ART given 1p','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1p\n Clients active on ART given 1p\n \n 2024-05-20 13:48:47 UTC\n \n 2024-05-20 13:50: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 2755\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4682)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:18:47',4,'2024-05-20 19:20:15',4,0,NULL,NULL,NULL,'561c81ce-fac7-4f8c-8f4e-f1a2b13a278c'),(2756,'Clients active on ART given 1q','Clients active on ART given 1q','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1q\n Clients active on ART given 1q\n \n 2024-05-20 13:49:06 UTC\n \n 2024-05-20 13:50: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 2756\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4683)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:19:06',4,'2024-05-20 19:20:25',4,0,NULL,NULL,NULL,'7bf054d9-cb00-40a0-91e8-22520eab883b'),(2757,'Clients active on ART given 2c','Clients active on ART given 2c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2c\n Clients active on ART given 2c\n \n 2024-05-20 13:51:13 UTC\n \n 2024-05-20 13: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 2757\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 2210)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:21:13',4,'2024-05-20 19:22:49',4,0,NULL,NULL,NULL,'f49999c1-f44a-43ba-9874-23acc3e4d7fd'),(2758,'Clients active on ART given 2d','Clients active on ART given 2d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2d\n Clients active on ART given 2d\n \n 2024-05-20 13:51:37 UTC\n \n 2024-05-20 13:53: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 2758\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 2209)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:21:37',4,'2024-05-20 19:23:01',4,0,NULL,NULL,NULL,'baf9ff8c-c1ef-4ecf-9391-524eeb7a5b50'),(2759,'Clients active on ART given 2e','Clients active on ART given 2e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2e\n Clients active on ART given 2e\n \n 2024-05-20 13:52:01 UTC\n \n 2024-05-20 13:53: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 2759\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 3674)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:22:01',4,'2024-05-20 19:23:17',4,0,NULL,NULL,NULL,'717ff14f-50f2-4b3a-99a5-5652f752890d'),(2760,'Clients active on ART given 2f','Clients active on ART given 2f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2f\n Clients active on ART given 2f\n \n 2024-05-20 13:54:16 UTC\n \n 2024-05-20 13: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 2760\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 3675)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:24:16',4,'2024-05-20 19:26:31',4,0,NULL,NULL,NULL,'045a03b9-678e-48a4-a620-0608a71b7f8f'),(2761,'Clients active on ART given 2g','Clients active on ART given 2g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2g\n Clients active on ART given 2g\n \n 2024-05-20 13:54:46 UTC\n \n 2024-05-20 13:56: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 2761\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 3676)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:24:46',4,'2024-05-20 19:26:40',4,0,NULL,NULL,NULL,'6f7557be-917a-43f7-a45c-581e417fd7ff'),(2762,'Clients active on ART given 2h','Clients active on ART given 2h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2h\n Clients active on ART given 2h\n \n 2024-05-20 13:55:26 UTC\n \n 2024-05-20 13: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 2762\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 3677)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:25:26',4,'2024-05-20 19:26:54',4,0,NULL,NULL,NULL,'26cb732c-602e-4271-84f6-65fff5003fc2'),(2763,'Clients active on ART given 2i','Clients active on ART given 2i','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2i\n Clients active on ART given 2i\n \n 2024-05-20 13:58:14 UTC\n \n 2024-05-20 13:59: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 2763\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 3678)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:28:14',4,'2024-05-20 19:29:37',4,0,NULL,NULL,NULL,'0d3cfa84-82de-4499-bec2-0274caf442f5'),(2764,'Clients active on ART given 2j','Clients active on ART given 2j','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2j\n Clients active on ART given 2j\n \n 2024-05-20 13:58:37 UTC\n \n 2024-05-20 13:59: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 2764\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4689)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:28:37',4,'2024-05-20 19:29:51',4,0,NULL,NULL,NULL,'10cb285e-5aa9-4b16-902e-9a0a9a3616ef'),(2765,'Clients active on ART given 2k','Clients active on ART given 2k','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2k\n Clients active on ART given 2k\n \n 2024-05-20 13:59:02 UTC\n \n 2024-05-20 14: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 2765\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4690)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:29:02',4,'2024-05-20 19:30:09',4,0,NULL,NULL,NULL,'4a16ab9d-2cd0-4cc3-9f07-9650ff676b34'),(2766,'Clients active on ART given 2L','Clients active on ART given 2L','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2L\n Clients active on ART given 2L\n \n 2024-05-20 14:01:22 UTC\n \n 2024-05-20 14:03: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 2766\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4691)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:31:22',4,'2024-05-20 19:33:10',4,0,NULL,NULL,NULL,'b036efb6-40d8-4965-a532-55e2f7999f01'),(2767,'Clients active on ART given 2m','Clients active on ART given 2m','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2m\n Clients active on ART given 2m\n \n 2024-05-20 14:01:44 UTC\n \n 2024-05-20 14:03: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 2767\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4692)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:31:44',4,'2024-05-20 19:33:19',4,0,NULL,NULL,NULL,'c80c5c21-bf59-4f25-80d9-1e09644befdd'),(2768,'Clients active on ART given 2n','Clients active on ART given 2n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2n\n Clients active on ART given 2n\n \n 2024-05-20 14:02:39 UTC\n \n 2024-05-20 14:03: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 2768\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4693)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:32:39',4,'2024-05-20 19:33:31',4,0,NULL,NULL,NULL,'755eddc1-42e8-4efb-a725-a4a0aeeabdd2'),(2769,'Clients active on ART given 2o','Clients active on ART given 2o','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2o\n Clients active on ART given 2o\n \n 2024-05-20 14:04:27 UTC\n \n 2024-05-20 14:05: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 2769\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4694)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:34:27',4,'2024-05-20 19:35:45',4,0,NULL,NULL,NULL,'b590190d-0d6c-4336-a557-82b1404882bd'),(2770,'Clients active on ART given 2p','Clients active on ART given 2p','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2p\n Clients active on ART given 2p\n \n 2024-05-20 14:04:46 UTC\n \n 2024-05-20 14:06: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 2770\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4695)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:34:46',4,'2024-05-20 19:36:00',4,0,NULL,NULL,NULL,'86c034fc-0b31-4cec-a0ed-51387c701fea'),(2771,'Clients active on ART given 2q','Clients active on ART given 2q','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2q\n Clients active on ART given 2q\n \n 2024-05-20 14:05:07 UTC\n \n 2024-05-20 14:06: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 2771\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4849)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:35:07',4,'2024-05-20 19:36:17',4,0,NULL,NULL,NULL,'f1209697-bac1-4737-981a-c68cac28935b'),(2772,'Clients active on ART given 2r','Clients active on ART given 2r','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2r\n Clients active on ART given 2r\n \n 2024-05-20 14:07:09 UTC\n \n 2024-05-20 14:08: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 2772\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4850)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:37:09',4,'2024-05-20 19:38:05',4,0,NULL,NULL,NULL,'3ceb9695-bd4e-438b-a436-190e6307fce2'),(2773,'Clients active on ART given 2s','Clients active on ART given 2s','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2s\n Clients active on ART given 2s\n \n 2024-05-20 14:07:31 UTC\n \n 2024-05-20 14:08: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 2773\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4851)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:37:31',4,'2024-05-20 19:38:18',4,0,NULL,NULL,NULL,'dfd94bf8-5b65-48cf-bd7d-70c742f4289e'),(2774,'Clients active on ART given 3a','Clients active on ART given 3a','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 3a\n Clients active on ART given 3a\n \n 2024-05-20 14:11:56 UTC\n \n 2024-05-20 14:14: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 2774\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 3683)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:41:56',4,'2024-05-20 19:44:13',4,0,NULL,NULL,NULL,'83329346-47a1-417e-8d35-e136340a63fc'),(2775,'Clients active on ART given 3b','Clients active on ART given 3b','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 3b\n Clients active on ART given 3b\n \n 2024-05-20 14:13:15 UTC\n \n 2024-05-20 14:14: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 2775\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 3684)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:43:15',4,'2024-05-20 19:44:22',4,0,NULL,NULL,NULL,'c048a3b6-f8e4-422d-a5ed-f717c50e3fca'),(2776,'Clients active on ART given 3c','Clients active on ART given 3c','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 3c\n Clients active on ART given 3c\n \n 2024-05-20 14:13:41 UTC\n \n 2024-05-20 14: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 2776\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 3685)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:43:41',4,'2024-05-20 19:44:33',4,0,NULL,NULL,NULL,'a24bcf43-9d24-4656-b8d6-9ca5daa689e8'),(2777,'Clients active on ART given 3d','Clients active on ART given 3d','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 3d\n Clients active on ART given 3d\n \n 2024-05-20 14:15:16 UTC\n \n 2024-05-20 14:16: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 2777\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4706)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:45:16',4,'2024-05-20 19:46:27',4,0,NULL,NULL,NULL,'410a8875-0d12-4ffd-9d81-ff4ed94310ac'),(2778,'Clients active on ART given 3e','Clients active on ART given 3e','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 3e\n Clients active on ART given 3e\n \n 2024-05-20 14:15:36 UTC\n \n 2024-05-20 14:16: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 2778\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4707)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:45:36',4,'2024-05-20 19:46:37',4,0,NULL,NULL,NULL,'4d08f326-3c94-4ecc-8f0e-d71d19d9b6ff'),(2779,'Clients active on ART given 3f','Clients active on ART given 3f','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 3f\n Clients active on ART given 3f\n \n 2024-05-20 14:15:56 UTC\n \n 2024-05-20 14:16: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 2779\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4708)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:45:56',4,'2024-05-20 19:46:49',4,0,NULL,NULL,NULL,'7ba9230d-0329-4fd5-ae90-9cc35a4cb093'),(2780,'Clients active on ART given 3g','Clients active on ART given 3g','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 3g\n Clients active on ART given 3g\n \n 2024-05-20 14:17:38 UTC\n \n 2024-05-21 09:52: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 2780\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4709)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:47:38',4,'2024-05-21 15:22:33',4,0,NULL,NULL,NULL,'c2a2f15b-5e11-4bc1-96a5-2943990dd81a'),(2781,'Clients active on ART given 3h','Clients active on ART given 3h','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 3h\n Clients active on ART given 3h\n \n 2024-05-20 14:17:55 UTC\n \n 2024-05-20 14:18: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 2781\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 (Select Id \n FROM \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 MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \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 ) AS Newly_Initiated_ART_Clients) \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id \n \n from obs o \n -- GIVEN MMD SUPPLY \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 \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 -- 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 \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 = 3753 \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.value_coded =1 and o.voided=0 \n and cast(o.obs_datetime as date) = cast(max_observation as date) \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 \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 = 4710)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \n))\n','2024-05-20 19:47:55',4,'2024-05-20 19:48:41',4,0,NULL,NULL,NULL,'21c9ca90-628e-4681-9092-2f62d9e9803f'),(2782,'Clients active on ART given 1c','Clients active on ART given 1c','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1c\n Clients active on ART given 1c\n \n 2024-05-21 08:08:31 UTC\n \n 2024-05-21 08:11: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 2782\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 13:38:31',4,'2024-05-21 13:41:57',4,0,NULL,NULL,NULL,'1ac4b2d2-d3ff-4828-8aff-ec4f1d56aa04'),(2783,'Clients active on ART given 1d','Clients active on ART given 1d','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1d\n Clients active on ART given 1d\n \n 2024-05-21 08:10:19 UTC\n \n 2024-05-21 08:14: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 2783\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 13:40:19',4,'2024-05-21 13:44:06',4,0,NULL,NULL,NULL,'ee811881-946f-44f8-b790-ba9957bf09e9'),(2784,'Clients active on ART given 1e','Clients active on ART given 1e','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1e\n Clients active on ART given 1e\n \n 2024-05-21 08:10:46 UTC\n \n 2024-05-21 08:14: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 2784\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 13:40:46',4,'2024-05-21 13:44:28',4,0,NULL,NULL,NULL,'3cd68651-b5d1-4388-84c6-4332ff0f980e'),(2785,'Clients active on ART given 1f','Clients active on ART given 1f','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1f\n Clients active on ART given 1f\n \n 2024-05-21 08:11:12 UTC\n \n 2024-05-21 08:14: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 2785\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 13:41:12',4,'2024-05-21 13:44:51',4,0,NULL,NULL,NULL,'3e9f0e9f-5160-4932-9693-44c39a6084b5'),(2786,'Clients active on ART given 1g','Clients active on ART given 1g','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1g\n Clients active on ART given 1g\n \n 2024-05-21 08:13:10 UTC\n \n 2024-05-21 08:19: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 2786\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 13:43:10',4,'2024-05-21 13:49:27',4,0,NULL,NULL,NULL,'526d57a3-7509-41fc-a166-b875e38b1467'),(2787,'Clients active on ART given 1h','Clients active on ART given 1h','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1h\n Clients active on ART given 1h\n \n 2024-05-21 08:15:48 UTC\n \n 2024-05-21 08:50: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 2787\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 13:45:48',4,'2024-05-21 14:20:46',4,0,NULL,NULL,NULL,'fd2b7604-51ce-44cb-bed9-7c2e16c62c6d'),(2788,'Clients active on ART given 1j','Clients active on ART given 1j','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1j\n Clients active on ART given 1j\n \n 2024-05-21 08:16:29 UTC\n \n 2024-05-21 08: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 2788\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 13:46:29',4,'2024-05-21 14:21:06',4,0,NULL,NULL,NULL,'22f9261e-b351-4d69-a2a9-6bf373a67fbd'),(2789,'Clients active on ART given 1k','Clients active on ART given 1k','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1k\n Clients active on ART given 1k\n \n 2024-05-21 08:17:52 UTC\n \n 2024-05-21 08: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 2789\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 13:47:52',4,'2024-05-21 14:24:59',4,0,NULL,NULL,NULL,'807903b7-91dc-4e62-aa85-fe1d9e35a040'),(2790,'Clients active on ART given 1m','Clients active on ART given 1m','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1m\n Clients active on ART given 1m\n \n 2024-05-21 08:54:29 UTC\n \n 2024-05-21 08:57: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 2790\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 14:24:29',4,'2024-05-21 14:27:03',4,0,NULL,NULL,NULL,'23132bf9-e526-4a7e-ac87-41b6e4e4868b'),(2791,'Clients active on ART given 1n','Clients active on ART given 1n','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1n\n Clients active on ART given 1n\n \n 2024-05-21 08:55:47 UTC\n \n 2024-05-21 08:57: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 2791\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 14:25:47',4,'2024-05-21 14:27:56',4,0,NULL,NULL,NULL,'1ed15ca2-1d89-49c2-a020-6d4f46e1e874'),(2792,'Clients active on ART given 1p','Clients active on ART given 1p','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1p\n Clients active on ART given 1p\n \n 2024-05-21 08:56:40 UTC\n \n 2024-05-21 08: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 2792\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 14:26:40',4,'2024-05-21 14:28:59',4,0,NULL,NULL,NULL,'03360fd3-4ac8-4b0d-b3d7-f37e6c4a3fc0'),(2793,'Clients active on ART given 1q','Clients active on ART given 1q','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 1q\n Clients active on ART given 1q\n \n 2024-05-21 08:58:30 UTC\n \n 2024-05-21 08: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 2793\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 14:28:30',4,'2024-05-21 14:29:49',4,0,NULL,NULL,NULL,'60d01dbe-3ff8-4a98-a88d-7e3a773b320e'),(2794,'Clients active on ART given 2c','Clients active on ART given 2c','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2c\n Clients active on ART given 2c\n \n 2024-05-21 09:00:39 UTC\n \n 2024-05-21 09:02: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 2794\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 14:30:39',4,'2024-05-21 14:32:15',4,0,NULL,NULL,NULL,'6306eda8-d44c-4034-8344-9614d1f57401'),(2795,'Clients active on ART given 2d','Clients active on ART given 2d','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2d\n Clients active on ART given 2d\n \n 2024-05-21 09:01:09 UTC\n \n 2024-05-21 09:03: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 2795\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 14:31:09',4,'2024-05-21 14:33:27',4,0,NULL,NULL,NULL,'1fa0cfe4-9123-485b-bc57-a1e4a1e4449f'),(2796,'Clients active on ART given 2e','Clients active on ART given 2e','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2e\n Clients active on ART given 2e\n \n 2024-05-21 09:01:45 UTC\n \n 2024-05-21 09:03: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 2796\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 14:31:45',4,'2024-05-21 14:33:44',4,0,NULL,NULL,NULL,'79ec3f68-8420-4f0b-914a-83146e266c8b'),(2797,'Clients active on ART given 2f','Clients active on ART given 2f','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2f\n Clients active on ART given 2f\n \n 2024-05-21 09:03:00 UTC\n \n 2024-05-21 09:26: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 2797\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 14:33:00',4,'2024-05-21 14:56:55',4,0,NULL,NULL,NULL,'3603a3e4-c38c-46c5-b28c-915988218c00'),(2798,'Clients active on ART given 2g','Clients active on ART given 2g','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2g\n Clients active on ART given 2g\n \n 2024-05-21 09:04:25 UTC\n \n 2024-05-21 09:28: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 2798\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 14:34:25',4,'2024-05-21 14:58:14',4,0,NULL,NULL,NULL,'f0074629-0aa3-4fb5-9f4f-0e09570a51cc'),(2799,'Clients active on ART given 2h','Clients active on ART given 2h','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2h\n Clients active on ART given 2h\n \n 2024-05-21 09:05:22 UTC\n \n 2024-05-21 09:28:38 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 2799\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 14:35:22',4,'2024-05-21 14:58:38',4,0,NULL,NULL,NULL,'674c044f-4fc9-46cc-b3a5-8a0ac6fb5e05'),(2800,'Clients active on ART given 2i','Clients active on ART given 2i','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2i\n Clients active on ART given 2i\n \n 2024-05-21 09:27:43 UTC\n \n 2024-05-21 09:32: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 2800\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 14:57:43',4,'2024-05-21 15:02:01',4,0,NULL,NULL,NULL,'9fbc5b95-e848-45c5-aec2-729633d89429'),(2801,'Clients active on ART given 2j','Clients active on ART given 2j','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2j\n Clients active on ART given 2j\n \n 2024-05-21 09:29:14 UTC\n \n 2024-05-21 09:32: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 2801\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 14:59:14',4,'2024-05-21 15:02:29',4,0,NULL,NULL,NULL,'90b06a80-c6f3-47e7-8da0-1c215bd0a111'),(2802,'Clients active on ART given 2k','Clients active on ART given 2k','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2k\n Clients active on ART given 2k\n \n 2024-05-21 09:30:57 UTC\n \n 2024-05-21 09: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 2802\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:00:57',4,'2024-05-21 15:03:00',4,0,NULL,NULL,NULL,'4f797041-f63c-42ae-a639-4a5f8e073c2e'),(2803,'Clients active on ART given 2L','Clients active on ART given 2L','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2L\n Clients active on ART given 2L\n \n 2024-05-21 09:33:17 UTC\n \n 2024-05-21 09:34: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 2803\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:03:17',4,'2024-05-21 15:04:53',4,0,NULL,NULL,NULL,'1cc648ca-84c8-496b-a80b-a00d6fa4623d'),(2804,'Clients active on ART given 2m','Clients active on ART given 2m','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2m\n Clients active on ART given 2m\n \n 2024-05-21 09:33:39 UTC\n \n 2024-05-21 09:35: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 2804\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:03:39',4,'2024-05-21 15:05:22',4,0,NULL,NULL,NULL,'7963c1b5-fd4d-4228-9352-f5bc99606e07'),(2805,'Clients active on ART given 2n','Clients active on ART given 2n','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2n\n Clients active on ART given 2n\n \n 2024-05-21 09:34:28 UTC\n \n 2024-05-21 09:36: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 2805\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:04:28',4,'2024-05-21 15:06:19',4,0,NULL,NULL,NULL,'2a308a8e-8db8-48f2-a016-ab1c6225d713'),(2806,'Clients active on ART given 2o','Clients active on ART given 2o','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2o\n Clients active on ART given 2o\n \n 2024-05-21 09:36:39 UTC\n \n 2024-05-21 09:38: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 2806\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:06:39',4,'2024-05-21 15:08:35',4,0,NULL,NULL,NULL,'2d918db9-5c69-4ac4-b891-129cf92139c8'),(2807,'Clients active on ART given 2p','Clients active on ART given 2p','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2p\n Clients active on ART given 2p\n \n 2024-05-21 09:37:02 UTC\n \n 2024-05-21 09:39: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 2807\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:07:02',4,'2024-05-21 15:09:00',4,0,NULL,NULL,NULL,'c3fe8f52-3470-46a2-9d45-4c947d776a72'),(2808,'Clients active on ART given 2q','Clients active on ART given 2q','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2q\n Clients active on ART given 2q\n \n 2024-05-21 09:37:27 UTC\n \n 2024-05-21 09:39: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 2808\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:07:27',4,'2024-05-21 15:09:24',4,0,NULL,NULL,NULL,'79f97ca4-27e8-40c5-9240-7a498f1666fd'),(2809,'Clients active on ART given 2r','Clients active on ART given 2r','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2r\n Clients active on ART given 2r\n \n 2024-05-21 09:39:54 UTC\n \n 2024-05-21 09:41: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 2809\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:09:54',4,'2024-05-21 15:11:26',4,0,NULL,NULL,NULL,'7644efb5-028c-48df-ad61-d5e9770d135e'),(2810,'Clients active on ART given 2s','Clients active on ART given 2s','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 2s\n Clients active on ART given 2s\n \n 2024-05-21 09:40:15 UTC\n \n 2024-05-21 09:41: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 2810\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:10:15',4,'2024-05-21 15:11:47',4,0,NULL,NULL,NULL,'e6a92d87-1d72-4c97-aeae-5d8eaaffb46c'),(2811,'Clients active on ART given 3a','Clients active on ART given 3a','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 3a\n Clients active on ART given 3a\n \n 2024-05-21 09:45:02 UTC\n \n 2024-05-21 09:47: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 2811\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:15:02',4,'2024-05-21 15:17:11',4,0,NULL,NULL,NULL,'0810b6e2-7138-4dcb-9a3e-b89d9e2ab935'),(2812,'Clients active on ART given 3b','Clients active on ART given 3b','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 3b\n Clients active on ART given 3b\n \n 2024-05-21 09:45:23 UTC\n \n 2024-05-21 09:47: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 2812\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:15:23',4,'2024-05-21 15:17:31',4,0,NULL,NULL,NULL,'46ddb805-e42f-4c70-844c-f8d567b12330'),(2813,'Clients active on ART given 3c','Clients active on ART given 3c','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 3c\n Clients active on ART given 3c\n \n 2024-05-21 09:45:44 UTC\n \n 2024-05-21 09:47: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 2813\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:15:44',4,'2024-05-21 15:17:51',4,0,NULL,NULL,NULL,'29145021-34fe-4dad-bd76-ae67749ad9ad'),(2814,'Clients active on ART given 3d','Clients active on ART given 3d','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 3d\n Clients active on ART given 3d\n \n 2024-05-21 09:48:07 UTC\n \n 2024-05-21 09:50: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 2814\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:18:07',4,'2024-05-21 15:20:08',4,0,NULL,NULL,NULL,'9c2dd0ad-5675-42ae-afa7-555b83c8584f'),(2815,'Clients active on ART given 3e','Clients active on ART given 3e','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 3e\n Clients active on ART given 3e\n \n 2024-05-21 09:48:26 UTC\n \n 2024-05-21 09:50: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 2815\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:18:26',4,'2024-05-21 15:20:27',4,0,NULL,NULL,NULL,'6d550065-fe78-441e-8464-909db6aeb4df'),(2816,'Clients active on ART given 3f','Clients active on ART given 3f','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 3f\n Clients active on ART given 3f\n \n 2024-05-21 09:48:51 UTC\n \n 2024-05-21 09:50: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 2816\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:18:51',4,'2024-05-21 15:20:48',4,0,NULL,NULL,NULL,'4011ecc2-eb97-42b4-b141-e150c098402f'),(2817,'Clients active on ART given 3g','Clients active on ART given 3g','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 3g\n Clients active on ART given 3g\n \n 2024-05-21 09:51:04 UTC\n \n 2024-05-21 09: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 2817\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:21:04',4,'2024-05-21 15:23:51',4,0,NULL,NULL,NULL,'a87c818a-72af-42c2-92ca-b1833eea824e'),(2818,'Clients active on ART given 3h','Clients active on ART given 3h','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients active on ART given 3h\n Clients active on ART given 3h\n \n 2024-05-21 09:51:26 UTC\n \n 2024-05-21 09:53: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 2818\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2024-05-21 15:21:26',4,'2024-05-21 15:23:29',4,0,NULL,NULL,NULL,'2816e1b5-f1ce-4e73-a28b-e6e7c446ed2c'),(2819,'First ANC Visits in 1st trimester in Lesotho','First ANC Visits in 1st trimester in Lesotho','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n First ANC Visits in 1st trimester in Lesotho\n First ANC Visits in 1st trimester in Lesotho\n \n 2024-05-24 09:20:10 UTC\n \n 2024-05-29 11:04: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 2819\n \nSELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4658 and B.value_coded = 4659 -- 1st ANC \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)First_ANC_Visits \n \ninner join \n-- first trimester \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 2423 and o.voided = 0 \n and o.value_numeric <= 12 -- first trimester \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.voided = 0 \n)as first_trimester \non first_trimester.encounter_id = First_ANC_Visits.encounter_id \n \ninner join \n \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 5422 and o.value_coded = 1 -- in Lesotho \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.voided = 0 \n)as in_country \non in_country.encounter_id = First_ANC_Visits.encounter_id\n','2024-05-24 14:50:10',4,'2024-05-29 16:34:28',4,0,NULL,NULL,NULL,'dd59ba6a-fd33-4968-8177-cbe8c2f72703'),(2820,'First ANC Visits in 2nd trimester in Lesotho','First ANC Visits in 2nd trimester in Lesotho','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n First ANC Visits in 2nd trimester in Lesotho\n First ANC Visits in 2nd trimester in Lesotho\n \n 2024-05-29 10:59:06 UTC\n \n 2024-05-29 11: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 2820\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4658 and B.value_coded = 4659 -- 1st ANC \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)First_ANC_Visits \n \ninner join \n-- second trimester \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 2423 and o.voided = 0 \n and o.value_numeric > 12 and o.value_numeric <= 27-- second trimester \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.voided = 0 \n)as first_trimester \non first_trimester.encounter_id = First_ANC_Visits.encounter_id \n \ninner join \n \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 5422 and o.value_coded = 1 -- in Lesotho \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.voided = 0 \n)as in_country \non in_country.encounter_id = First_ANC_Visits.encounter_id\n','2024-05-29 16:29:06',4,'2024-05-29 16:35:14',4,0,NULL,NULL,NULL,'7b6c21c2-52da-4987-a57c-8e14c286a3c6'),(2821,'First ANC Visits in 3rd trimester in Lesotho','First ANC Visits in 3rd trimester in Lesotho','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n First ANC Visits in 3rd trimester in Lesotho\n First ANC Visits in 3rd trimester in Lesotho\n \n 2024-05-29 11:05:37 UTC\n \n 2024-05-29 11:06: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 2821\n \nSELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4658 and B.value_coded = 4659 -- 1st ANC \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)First_ANC_Visits \n \ninner join \n-- third trimester \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 2423 and o.voided = 0 \n and o.value_numeric > 27-- third trimester \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.voided = 0 \n)as first_trimester \non first_trimester.encounter_id = First_ANC_Visits.encounter_id \n \ninner join \n \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 5422 and o.value_coded = 1 -- in Lesotho \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.voided = 0 \n)as in_country \non in_country.encounter_id = First_ANC_Visits.encounter_id\n','2024-05-29 16:35:37',4,'2024-05-29 16:36:11',4,0,NULL,NULL,NULL,'3885cf88-2212-49fa-b780-dc792de5cec3'),(2822,'First ANC Visits in 1st trimester outside Lesotho','First ANC Visits in 1st trimester outside Lesotho','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n First ANC Visits in 1st trimester outside Lesotho\n First ANC Visits in 1st trimester outside Lesotho\n \n 2024-05-29 11:20:38 UTC\n \n 2024-05-29 11:22: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 2822\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4658 and B.value_coded = 4659 -- 1st ANC \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)First_ANC_Visits \n \ninner join \n-- first trimester \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 2423 and o.voided = 0 \n and o.value_numeric <= 12 -- first trimester \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.voided = 0 \n)as first_trimester \non first_trimester.encounter_id = First_ANC_Visits.encounter_id \n \ninner join \n \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 5422 and o.value_coded = 2 -- outside Lesotho \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.voided = 0 \n)as in_country \non in_country.encounter_id = First_ANC_Visits.encounter_id\n','2024-05-29 16:50:38',4,'2024-05-29 16:52:03',4,0,NULL,NULL,NULL,'427e1069-22ea-40c5-8fd7-3001a63dcf5d'),(2823,'First ANC Visits in 2nd trimester outside Lesotho','First ANC Visits in 2nd trimester outside Lesotho','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n First ANC Visits in 2nd trimester outside Lesotho\n First ANC Visits in 2nd trimester outside Lesotho\n \n 2024-05-29 11:24:09 UTC\n \n 2024-05-29 11:24: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 2823\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4658 and B.value_coded = 4659 -- 1st ANC \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)First_ANC_Visits \n \ninner join \n-- second trimester \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 2423 and o.voided = 0 \n and o.value_numeric > 12 and o.value_numeric <= 27-- second trimester \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.voided = 0 \n)as first_trimester \non first_trimester.encounter_id = First_ANC_Visits.encounter_id \n \ninner join \n \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 5422 and o.value_coded = 2 -- outside Lesotho \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.voided = 0 \n)as in_country \non in_country.encounter_id = First_ANC_Visits.encounter_id\n','2024-05-29 16:54:09',4,'2024-05-29 16:54:40',4,0,NULL,NULL,NULL,'d57913b6-347f-4b12-b085-0d548b6a76f3'),(2824,'First ANC Visits in 3rd trimester outside Lesotho','First ANC Visits in 3rd trimester outside Lesotho','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n First ANC Visits in 3rd trimester outside Lesotho\n First ANC Visits in 3rd trimester outside Lesotho\n \n 2024-05-29 11:26:15 UTC\n \n 2024-05-29 11:26: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 2824\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4658 and B.value_coded = 4659 -- 1st ANC \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)First_ANC_Visits \n \ninner join \n-- third trimester \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 2423 and o.voided = 0 \n and o.value_numeric > 27-- third trimester \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.voided = 0 \n)as first_trimester \non first_trimester.encounter_id = First_ANC_Visits.encounter_id \n \ninner join \n \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 5422 and o.value_coded = 2 -- outside Lesotho \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.voided = 0 \n)as in_country \non in_country.encounter_id = First_ANC_Visits.encounter_id\n','2024-05-29 16:56:15',4,'2024-05-29 16:56:41',4,0,NULL,NULL,NULL,'450076d5-75be-4d23-a96d-31410c1d8a05'),(2825,'First ANC Visits - High Risk Pregnancies','First ANC Visits - High Risk Pregnancies','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n First ANC Visits - High Risk Pregnancies\n First ANC Visits - High Risk Pregnancies\n \n 2024-05-29 11:48:43 UTC\n \n 2024-06-12 13:09: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 2825\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4658 and B.value_coded = 4659 -- 1st ANC \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)First_ANC_Visits \n \ninner join \n-- High Risk Pregnancy \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 4352 and o.value_coded not in (4353) \nand o.voided = 0 -- High Risk Pregnancy \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.voided = 0 \n)as High_Risk_Preg \non High_Risk_Preg.encounter_id = First_ANC_Visits.encounter_id\n','2024-05-29 17:18:43',4,'2024-06-12 18:39:55',4,0,NULL,NULL,NULL,'0f608ebc-9e25-4d22-8f53-d2d499b28425'),(2826,'Second Follow-up ANC visit ','Second Follow-up ANC visit ','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Second Follow-up ANC visit \n Second Follow-up ANC visit \n \n 2024-06-10 14:20:48 UTC\n \n 2024-06-10 14:30: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 2826\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4658 and B.value_coded = 4660 -- Subsequent ANC Visit \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)Subsequent_Visits \n \ninner join \n-- first trimester \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 4510 and o.voided = 0 -- visit order number \n and o.value_coded = 1723 -- Second Visit \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.voided = 0 \n)as visit \non visit.encounter_id = Subsequent_Visits.encounter_id \n\n','2024-06-10 19:50:48',4,'2024-06-10 20:00:51',4,0,NULL,NULL,NULL,'700f9783-23b4-41d4-a8f5-09ebeebc4697'),(2827,'Third Follow-up ANC visit','Third Follow-up ANC visit','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Third Follow-up ANC visit\n Third Follow-up ANC visit\n \n 2024-06-10 14:28:36 UTC\n \n 2024-06-10 14:32: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 2827\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4658 and B.value_coded = 4660 -- Subsequent ANC Visit \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)Subsequent_Visits \n \ninner join \n-- first trimester \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 4510 and o.voided = 0 -- visit order number \n and o.value_coded = 1724 -- Third Visit \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.voided = 0 \n)as visit \non visit.encounter_id = Subsequent_Visits.encounter_id \n\n','2024-06-10 19:58:36',4,'2024-06-10 20:02:05',4,0,NULL,NULL,NULL,'96667310-03f2-4755-beb6-a56ee0258523'),(2828,'Fourth Follow-up ANC visit','Fourth Follow-up ANC visit','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Fourth Follow-up ANC visit\n Fourth Follow-up ANC visit\n \n 2024-06-10 14:29:04 UTC\n \n 2024-06-10 14:35: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 2828\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4658 and B.value_coded = 4660 -- Subsequent ANC Visit \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)Subsequent_Visits \n \ninner join \n-- first trimester \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 4510 and o.voided = 0 -- visit order number \n and o.value_coded = 4507 -- Fourth Visit \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.voided = 0 \n)as visit \non visit.encounter_id = Subsequent_Visits.encounter_id \n\n','2024-06-10 19:59:04',4,'2024-06-10 20:05:24',4,0,NULL,NULL,NULL,'4c6d0e21-5f0f-41b7-ae5e-40905d346e5a'),(2829,'Fifth Follow-up ANC visit','Fifth Follow-up ANC visit','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Fifth Follow-up ANC visit\n Fifth Follow-up ANC visit\n \n 2024-06-10 14:32:59 UTC\n \n 2024-06-10 14:33: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 2829\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4658 and B.value_coded = 4660 -- Subsequent ANC Visit \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)Subsequent_Visits \n \ninner join \n-- first trimester \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 4510 and o.voided = 0 -- visit order number \n and o.value_coded = 4508 -- Fifth Visit \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.voided = 0 \n)as visit \non visit.encounter_id = Subsequent_Visits.encounter_id \n\n','2024-06-10 20:02:59',4,'2024-06-10 20:03:41',4,0,NULL,NULL,NULL,'b0e58316-dea5-4642-b467-d6fa5d579dc1'),(2830,'Sixth Follow-up ANC visit','Sixth Follow-up ANC visit','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Sixth Follow-up ANC visit\n Sixth Follow-up ANC visit\n \n 2024-06-10 14:36:38 UTC\n \n 2024-06-10 14:39: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 2830\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4658 and B.value_coded = 4660 -- Subsequent ANC Visit \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)Subsequent_Visits \n \ninner join \n-- first trimester \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 4510 -- visit order number \n and o.value_coded = 4509 -- Sixth Visit \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.voided = 0 \n)as visit \non visit.encounter_id = Subsequent_Visits.encounter_id \n\n','2024-06-10 20:06:38',4,'2024-06-10 20:09:29',4,0,NULL,NULL,NULL,'fa3e26d0-2e18-4b45-bbae-2b395c5b9242'),(2831,'Seventh Follow-up ANC visit','Seventh Follow-up ANC visit','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Seventh Follow-up ANC visit\n Seventh Follow-up ANC visit\n \n 2024-06-10 14:37:50 UTC\n \n 2024-06-10 14:40: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 2831\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4658 and B.value_coded = 4660 -- Subsequent ANC Visit \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)Subsequent_Visits \n \ninner join \n-- first trimester \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 4510 -- visit order number \n and o.value_coded = 5994 -- Seventh Visit \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.voided = 0 \n)as visit \non visit.encounter_id = Subsequent_Visits.encounter_id \n\n','2024-06-10 20:07:50',4,'2024-06-10 20:10:08',4,0,NULL,NULL,NULL,'2619fba1-5453-4e53-a8a9-b10548593741'),(2832,'Eighth Follow-up ANC visit','Eighth Follow-up ANC visit','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Eighth Follow-up ANC visit\n Eighth Follow-up ANC visit\n \n 2024-06-10 14:38:20 UTC\n \n 2024-06-10 14:40: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 2832\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4658 and B.value_coded = 4660 -- Subsequent ANC Visit \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)Subsequent_Visits \n \ninner join \n-- first trimester \n( \n select o.person_id, o.encounter_id \n from obs o \n where o.concept_id = 4510 -- visit order number \n and o.value_coded = 5995 -- Eighth Visit \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.voided = 0 \n)as visit \non visit.encounter_id = Subsequent_Visits.encounter_id \n\n','2024-06-10 20:08:20',4,'2024-06-10 20:10:45',4,0,NULL,NULL,NULL,'b8337218-368a-47a3-9666-a9b798aa7dd0'),(2833,'Positive Syphilis results at <36 GA','Positive Syphilis results at <36 Gestational Age','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Positive Syphilis results at <36 GA\n Positive Syphilis results at <36 Gestational Age\n \n 2024-06-12 09:27:44 UTC\n \n 2024-06-12 09: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 2833\n SELECT Id \nFROM \n(select B.person_id as Id, obs_group_id,encounter_id \n from obs B \n where B.concept_id = 4305 and B.value_coded = 4306 -- Positive Syphilis Results \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n group by B.person_id \n)Syphilis_pos \n \ninner join \n-- gestational_age \n( \n select B.person_id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 1923 and B.value_numeric < 36 -- Gestation period \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n)gestational_age \non gestational_age.encounter_id = Syphilis_pos.encounter_id \n\n','2024-06-12 14:57:44',4,'2024-06-12 14:59:16',4,0,NULL,NULL,NULL,'5f1733cb-c2e3-4b42-b2db-9004054eea93'),(2834,'Positive Syphilis results at >36 GA','Positive Syphilis results at >=36 Gestational Age','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Positive Syphilis results at >36 GA\n Positive Syphilis results at >=36 Gestational Age\n \n 2024-06-12 09:31:37 UTC\n \n 2024-06-12 09:32: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 2834\n SELECT Id \nFROM \n(select B.person_id as Id, obs_group_id,encounter_id \n from obs B \n where B.concept_id = 4305 and B.value_coded = 4306 -- Positive Syphilis Results \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n group by B.person_id \n)Syphilis_pos \n \ninner join \n-- gestational_age \n( \n select B.person_id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 1923 and B.value_numeric >= 36 -- Gestation period \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n)gestational_age \non gestational_age.encounter_id = Syphilis_pos.encounter_id \n\n','2024-06-12 15:01:37',4,'2024-06-12 15:02:00',4,0,NULL,NULL,NULL,'4f5a7c43-d20e-4aad-857b-6a539754e63a'),(2835,'Syphilis Treatment Completed at 36+ GA','Syphilis Treatment Completed at 36+ Gestational Age','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Syphilis Treatment Completed at 36+ GA\n Syphilis Treatment Completed at 36+ Gestational Age\n \n 2024-06-12 10:04:49 UTC\n \n 2024-06-12 10:10: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 2835\n SELECT Id \nFROM \n( \n(select B.person_id as Id, obs_group_id,encounter_id \n from obs B \n where B.concept_id = 4305 and B.value_coded = 4306 -- Positive Syphilis Results \n -- and CAST(B.obs_datetime as date) >= CAST('2024-01-01' as date) \n and CAST(B.obs_datetime as date) <= CAST('2024-05-31' as date) \n and voided = 0 \n group by B.person_id \n)Syphilis_pos \n \ninner join \n-- gestational_age \n( \n select B.person_id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 1923 and B.value_numeric >= 36 -- Gestation period \n -- and CAST(B.obs_datetime as date) >= CAST('2024-01-01' as date) \n and CAST(B.obs_datetime as date) <= CAST('2024-05-31' as date) \n and voided = 0 \n)gestational_age \non gestational_age.encounter_id = Syphilis_pos.encounter_id \n \ninner join \n-- syphilis treatment completed \n( \n select B.person_id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 1732 and B.value_coded = 2146 -- treatment completed \n and CAST(B.obs_datetime as date) >= CAST('2024-01-01' as date) \n and CAST(B.obs_datetime as date) <= CAST('2024-05-31' as date) \n and voided = 0 \n)treatment_completion \non treatment_completion.encounter_id = Syphilis_pos.encounter_id \n) \n\n','2024-06-12 15:34:49',4,'2024-06-12 15:40:00',4,0,NULL,NULL,NULL,'7d0de066-6efe-43f4-9a9b-1ac0c09af108'),(2836,'Syphilis Treatment Completed at <36 GA','Syphilis Treatment Completed at <36 Gestational Age','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Syphilis Treatment Completed at <36 GA\n Syphilis Treatment Completed at <36 Gestational Age\n \n 2024-06-12 10:13:14 UTC\n \n 2024-06-12 10:13: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 2836\n SELECT Id \nFROM \n( \n(select B.person_id as Id, obs_group_id,encounter_id \n from obs B \n where B.concept_id = 4305 and B.value_coded = 4306 -- Positive Syphilis Results \n -- and CAST(B.obs_datetime as date) >= CAST('2024-01-01' as date) \n and CAST(B.obs_datetime as date) <= CAST('2024-05-31' as date) \n and voided = 0 \n group by B.person_id \n)Syphilis_pos \n \ninner join \n-- gestational_age \n( \n select B.person_id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 1923 and B.value_numeric < 36 -- Gestation period \n -- and CAST(B.obs_datetime as date) >= CAST('2024-01-01' as date) \n and CAST(B.obs_datetime as date) <= CAST('2024-05-31' as date) \n and voided = 0 \n)gestational_age \non gestational_age.encounter_id = Syphilis_pos.encounter_id \n \ninner join \n-- syphilis treatment completed \n( \n select B.person_id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 1732 and B.value_coded = 2146 -- treatment completed \n and CAST(B.obs_datetime as date) >= CAST('2024-01-01' as date) \n and CAST(B.obs_datetime as date) <= CAST('2024-05-31' as date) \n and voided = 0 \n)treatment_completion \non treatment_completion.encounter_id = Syphilis_pos.encounter_id \n) \n\n','2024-06-12 15:43:14',4,'2024-06-12 15:43:42',4,0,NULL,NULL,NULL,'a1b4a9a2-3c50-45ab-9d49-fb59b969d956'),(2837,'Hb < 12g at <36 GA','Hb < 12g/dl at < 36 weeks Gestational Age','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Hb < 12g at <36 GA\n Hb < 12g/dl at < 36 weeks Gestational Age\n \n 2024-06-12 10:33:40 UTC\n \n 2024-06-12 10:35: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 2837\n SELECT Id \nFROM \n( \n-- Haemoglobin (Hb) \n( \n select B.person_id as Id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 3204 and B.value_numeric < 12 -- Haemoglobin \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n)Haemoglobin \n \ninner join \n-- Gestational age \n( \n select B.person_id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 1923 and B.value_numeric < 36 -- Gestation period \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n)gestational_age \non gestational_age.encounter_id = Haemoglobin.encounter_id \n) \n\n','2024-06-12 16:03:40',4,'2024-06-12 16:05:46',4,0,NULL,NULL,NULL,'3b078b0a-695b-49f0-b92b-4ff230f4d1e4'),(2838,'Hb < 12g at 36+ GA','Hb < 12g/dl at 36+ weeks Gestational Age','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Hb < 12g at 36+ GA\n Hb < 12g/dl at 36+ weeks Gestational Age\n \n 2024-06-12 10:34:54 UTC\n \n 2024-06-12 10:35: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 2838\n SELECT Id \nFROM \n( \n-- Haemoglobin (Hb) \n( \n select B.person_id as Id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 3204 and B.value_numeric < 12 -- Haemoglobin \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n)Haemoglobin \n \ninner join \n-- Gestational age \n( \n select B.person_id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 1923 and B.value_numeric >= 36 -- Gestation period \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n)gestational_age \non gestational_age.encounter_id = Haemoglobin.encounter_id \n) \n\n','2024-06-12 16:04:54',4,'2024-06-12 16:05:56',4,0,NULL,NULL,NULL,'6685f49f-af81-4fc0-8dc9-d4847d1032e7'),(2839,'Hb >= 12g at <36 GA',' Hb >= 12g/dl at < 36 weeks Gestational Age','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Hb >= 12g at <36 GA\n Hb >= 12g/dl at < 36 weeks Gestational Age\n \n 2024-06-12 10:56:20 UTC\n \n 2024-06-12 10: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 2839\n SELECT Id \nFROM \n( \n-- Haemoglobin (Hb) \n( \n select B.person_id as Id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 3204 and B.value_numeric >= 12 -- Haemoglobin \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n)Haemoglobin \n \ninner join \n-- Gestational age \n( \n select B.person_id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 1923 and B.value_numeric < 36 -- Gestation period \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n)gestational_age \non gestational_age.encounter_id = Haemoglobin.encounter_id \n) \n\n','2024-06-12 16:26:20',4,'2024-06-12 16:28:01',4,0,NULL,NULL,NULL,'3fc002aa-2be3-404f-8707-1b6bb238138e'),(2840,'Hb >= 12g at 36+ GA','Hb >= 12g/dl at >= 36 weeks Gestational Age','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Hb >= 12g at 36+ GA\n Hb >= 12g/dl at >= 36 weeks Gestational Age\n \n 2024-06-12 10:57:18 UTC\n \n 2024-06-13 10:06: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 2840\n SELECT Id \nFROM \n( \n-- Haemoglobin (Hb) \n( \n select B.person_id as Id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 3204 and B.value_numeric >= 12 -- Haemoglobin \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n)Haemoglobin \n \ninner join \n-- Gestational age \n( \n select B.person_id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 1923 and B.value_numeric >= 36 -- Gestation period \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n)gestational_age \non gestational_age.encounter_id = Haemoglobin.encounter_id \n) \n\n','2024-06-12 16:27:18',4,'2024-06-13 15:36:34',4,0,NULL,NULL,NULL,'8c3d7f6f-4c21-4124-a40e-9cff51bb76fe'),(2841,'MUAC < 23 in ANC','MUAC < 23 in ANC','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n MUAC < 23 in ANC\n MUAC < 23 in ANC\n \n 2024-06-12 11:44:36 UTC\n \n 2024-06-12 11:44: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 2841\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B.encounter_id \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, encounter_id \n from obs where concept_id = 4301 -- Nutrition Assessment in ANC form \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.encounter_id = B.encounter_id \n where B.concept_id = 2086 and B.value_numeric < 23 -- MUAC less than 23 \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)MUAC\n','2024-06-12 17:14:36',4,'2024-06-12 17:14:56',4,0,NULL,NULL,NULL,'2f9aed17-e520-452d-9a1e-62d4443c98c7'),(2842,'ANC Clients initiated on TPT','ANC Clients initiated on TPT','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC Clients initiated on TPT\n ANC Clients initiated on TPT\n \n 2024-06-12 12:53:40 UTC\n \n 2024-06-12 13:00: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 2842\n SELECT Id \nFROM \n-- IPT Started \n( \n select B.person_id as Id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 4337 and B.value_coded = 2227 -- TB Treatment and IPT started \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n)IPT_Started\n','2024-06-12 18:23:40',4,'2024-06-12 18:30:34',4,0,NULL,NULL,NULL,'0d212a50-a5de-4bb3-bea9-d620bc310cab'),(2843,'ANC Clients referred for TB Treatment','ANC Clients referred for TB Treatment','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC Clients referred for TB Treatment\n ANC Clients referred for TB Treatment\n \n 2024-06-12 13:04:12 UTC\n \n 2024-06-12 13: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 2843\n SELECT Id \nFROM \n-- TB Referral \n( \n select B.person_id as Id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 4378 and B.value_coded = 4384 -- Referred for TB treatment \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n)TB_Referral\n','2024-06-12 18:34:12',4,'2024-06-12 18:36:13',4,0,NULL,NULL,NULL,'f2ed795a-052f-414e-bc7e-089a4eac4a16'),(2844,'ANC Clients already on ART at 1st ANC visit','ANC Clients already on ART at 1st ANC visit','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC Clients already on ART at 1st ANC visit\n ANC Clients already on ART at 1st ANC visit\n \n 2024-06-12 13:26:59 UTC\n \n 2024-06-12 13:39: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 2844\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4658 and B.value_coded = 4659 -- 1st ANC \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)First_ANC_Visits \n \ninner join \n-- Already on ART \n( \n select o.person_id, o.encounter_id, value_coded \n from obs o \n where o.concept_id = 4343 and o.value_coded = 4341 -- Already on ART \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.voided = 0 \n)as Already_on_ART \non Already_on_ART.encounter_id = First_ANC_Visits.encounter_id\n','2024-06-12 18:56:59',4,'2024-06-12 19:09:32',4,0,NULL,NULL,NULL,'c40751d8-10c0-479d-b6c5-218f6daf1f69'),(2845,'ANC Clients initiated on ART during pregnancy','ANC Clients initiated on ART during pregnancy','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC Clients initiated on ART during pregnancy\n ANC Clients initiated on ART during pregnancy\n \n 2024-06-12 13:36:45 UTC\n \n 2024-06-12 13:38: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 2845\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4343 and B.value_coded = 4342 -- Initiated on ART at ANC \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)Initiated_ANC\n','2024-06-12 19:06:45',4,'2024-06-12 19:08:06',4,0,NULL,NULL,NULL,'63cba477-192c-4b6b-af04-47b1f8844f47'),(2846,'Pregnancies protected against TT(Td)','Pregnancies protected against TT(Td)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Pregnancies protected against TT(Td)\n Pregnancies protected against TT(Td)\n \n 2024-06-12 13:50:53 UTC\n \n 2024-06-12 13:51: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 2846\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 4319 and B.value_numeric > 0 -- TT Current Dose \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)TT_Current_Dose\n','2024-06-12 19:20:53',4,'2024-06-12 19:21:55',4,0,NULL,NULL,NULL,'12a73f73-0e7d-4abe-ba81-a1ec3dac0ddd'),(2847,'ANC clients provided with Iron and Folate','ANC clients provided with Iron and Folate','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC clients provided with Iron and Folate\n ANC clients provided with Iron and Folate\n \n 2024-06-12 13:53:09 UTC\n \n 2024-06-13 09:34: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 2847\n SELECT distinct Id \nFROM \n( \n \n( \n select B.person_id as Id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 4299 and B.value_coded in (4668,1067) -- Given Iron \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n) \n \nUNION \n \n( \n select B.person_id as Id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 4300 and B.value_coded in (4668,1067) -- Given Folate \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n) \n)Iron_Folate\n','2024-06-12 19:23:09',4,'2024-06-13 15:04:44',4,0,NULL,NULL,NULL,'6f1cb704-cbec-400b-a7fc-29220fe69fe3'),(2848,'ANC clients provided with Calcium','ANC clients provided with Calcium','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC clients provided with Calcium\n ANC clients provided with Calcium\n \n 2024-06-12 13:53:54 UTC\n \n 2024-06-12 14:00: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 2848\n SELECT Id \nFROM \n-- Calcium \n( \n select B.person_id as Id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 5418 and B.value_coded in (4668,1067) -- Calcium \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n)Calcium\n','2024-06-12 19:23:54',4,'2024-06-12 19:30:00',4,0,NULL,NULL,NULL,'33a99132-7301-4a83-9fa3-ad368f75f6dd'),(2849,'ANC clients provided with Mebendazole /Albendazole','ANC clients provided with Mebendazole /Albendazole','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC clients provided with Mebendazole /Albendazole\n ANC clients provided with Mebendazole /Albendazole\n \n 2024-06-12 13:55:16 UTC\n \n 2024-06-12 13:55: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 2849\n','2024-06-12 19:25:16',4,'2024-06-12 19:25:21',4,0,NULL,NULL,NULL,'102b44dc-6d70-4b6e-8ddc-e07c0e6fc2ff'),(2850,'ANC clients provided with a negative Rhesus factor (-)','ANC clients provided with a negative Rhesus factor (-)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC clients provided with a negative Rhesus factor (-)\n ANC clients provided with a negative Rhesus factor (-)\n \n 2024-06-12 13:56:10 UTC\n \n 2024-06-12 14:10: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 2850\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B. encounter_id \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 = 4663 -- ANC form \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 B.concept_id = 1179 and B.value_coded in (4310,4312,4314,4316) -- Blood groups A-, B-, O -, AB- \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n or B.person_id in ( \n select B.person_id \n from obs B \n where B.concept_id = 5331 and B.value_coded = 5333 -- Negative Rhesus factor \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n ) \n group by B.person_id \n)Rhesus\n','2024-06-12 19:26:10',4,'2024-06-12 19:40:13',4,0,NULL,NULL,NULL,'383b2efe-3a17-467f-837a-3abecd88f019'),(2851,'ANC Clients with a known status before first ANC visits','ANC Clients with a known status before first ANC visits','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC Clients with a known status before first ANC visits\n ANC Clients with a known status before first ANC visits\n \n 2024-06-13 09:26:05 UTC\n \n 2024-06-13 09:46: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 2851\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B.encounter_id \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, encounter_id \n from obs where concept_id = 4663 -- ANC form \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.encounter_id = B.encounter_id \n where B.concept_id = 4427 and B.value_coded in (1738,1016) -- HIV Status Known Before Visit \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)Status_known_before_visit\n','2024-06-13 14:56:05',4,'2024-06-13 15:16:55',4,0,NULL,NULL,NULL,'48b38987-2cea-4dbb-b71e-3eaf4908f391'),(2852,'ANC Clients with a known HIV+ status at first ANC visit','ANC Clients with a known HIV+ status at first ANC visit','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC Clients with a known HIV+ status at first ANC visit\n ANC Clients with a known HIV+ status at first ANC visit\n \n 2024-06-13 09:51:58 UTC\n \n 2024-06-13 09:52: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 2852\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B.encounter_id \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, encounter_id \n from obs where concept_id = 4663 -- ANC form \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.encounter_id = B.encounter_id \n where B.concept_id = 4427 and B.value_coded = 1738 -- HIV Positive Status Known Before Visit \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)Status_known_before_visit\n','2024-06-13 15:21:58',4,'2024-06-13 15:22:45',4,0,NULL,NULL,NULL,'ddda5d39-f00c-415e-98ad-ea9f893c1025'),(2853,'ANC Clients with a known HIV- status at first ANC visit','ANC Clients with a known HIV- status at first ANC visit','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC Clients with a known HIV- status at first ANC visit\n ANC Clients with a known HIV- status at first ANC visit\n \n 2024-06-13 09:53:56 UTC\n \n 2024-06-13 09:54: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 2853\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B.encounter_id \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, encounter_id \n from obs where concept_id = 4663 -- ANC form \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.encounter_id = B.encounter_id \n where B.concept_id = 4427 and B.value_coded = 1016 -- HIV Negative Status Known Before Visit \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)Status_known_before_visit\n','2024-06-13 15:23:56',4,'2024-06-13 15:24:35',4,0,NULL,NULL,NULL,'29e91688-b526-49a9-a8f0-ea3e426a0db7'),(2854,'ANC Clients with initial tests during pregnancy','ANC Clients with initial tests during pregnancy','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC Clients with initial tests during pregnancy\n ANC Clients with initial tests during pregnancy\n \n 2024-06-13 10:01:13 UTC\n \n 2024-06-13 10: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 2854\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B.encounter_id \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, encounter_id \n from obs where concept_id = 4663 -- ANC form \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.encounter_id = B.encounter_id \n where B.concept_id = 1726 and B.value_coded = 2146 -- HIV test done during pregrancy \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)Test_during_pregnancy\n','2024-06-13 15:31:13',4,'2024-06-13 15:31:46',4,0,NULL,NULL,NULL,'dbae4299-d0ec-47d6-82e3-ea75a9919e5a'),(2855,'ANC clients with positive initial test during pregnancy','ANC clients with positive initial test during pregnancy','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC clients with positive initial test during pregnancy\n ANC clients with positive initial test during pregnancy\n \n 2024-06-13 10:03:04 UTC\n \n 2024-06-13 10:04: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 2855\n SELECT Id \nFROM \n(select B.person_id as Id, B.obs_group_id,B.encounter_id \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, encounter_id \n from obs where concept_id = 4663 -- ANC form \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.encounter_id = B.encounter_id \n where B.concept_id = 1740 and B.value_coded = 1738 -- Positive HIV Resuls \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)Test_during_pregnancy\n','2024-06-13 15:33:04',4,'2024-06-13 15:34:06',4,0,NULL,NULL,NULL,'45925e11-9837-4921-beaa-01c64a4bac35'),(2856,'ANC Clients tested at 36+ weeks GA','ANC Clients tested at 36+ weeks GA','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC Clients tested at 36+ weeks GA\n ANC Clients tested at 36+ weeks GA\n \n 2024-06-13 10:15:03 UTC\n \n 2024-06-13 10:15: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 2856\n SELECT Id \nFROM( \n(select B.person_id as Id, B.obs_group_id,B.encounter_id \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, encounter_id \n from obs where concept_id = 4663 -- ANC form \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.encounter_id = B.encounter_id \n where B.concept_id = 1726 and B.value_coded = 2146 -- HIV Test done \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)Test_during_pregnancy \n \ninner join \n-- Gestational age \n( \n select B.person_id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 1923 and B.value_numeric >= 36 -- Gestation period \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n)gestational_age \non gestational_age.encounter_id = Test_during_pregnancy.encounter_id \n)\n','2024-06-13 15:45:03',4,'2024-06-13 15:45:18',4,0,NULL,NULL,NULL,'ff38552c-cefa-4561-8dd3-a67a0ab097be'),(2857,'ANC Clients with a positive result tested at 36+ weeks GA','ANC Clients with a positive result tested at 36+ weeks GA','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC Clients with a positive result tested at 36+ weeks GA\n ANC Clients with a positive result tested at 36+ weeks GA\n \n 2024-06-13 10:16:31 UTC\n \n 2024-06-13 10:17: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 2857\n SELECT Id \nFROM( \n(select B.person_id as Id, B.obs_group_id,B.encounter_id \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, encounter_id \n from obs where concept_id = 4663 -- ANC form \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.encounter_id = B.encounter_id \n where B.concept_id = 1740 and B.value_coded = 1738 -- HIV Pos \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)Test_during_pregnancy \n \ninner join \n-- Gestational age \n( \n select B.person_id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 1923 and B.value_numeric >= 36 -- Gestation period \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n)gestational_age \non gestational_age.encounter_id = Test_during_pregnancy.encounter_id \n)\n','2024-06-13 15:46:31',4,'2024-06-13 15:47:31',4,0,NULL,NULL,NULL,'eadfca09-3eed-4e5d-870f-01b9c9c7b87e'),(2858,'ANC Clients with a negative result tested at 36+ weeks GA','ANC Clients with a negative result tested at 36+ weeks GA','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC Clients with a negative result tested at 36+ weeks GA\n ANC Clients with a negative result tested at 36+ weeks GA\n \n 2024-06-13 10:18:16 UTC\n \n 2024-06-13 10:19: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 2858\n SELECT Id \nFROM( \n(select B.person_id as Id, B.obs_group_id,B.encounter_id \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, encounter_id \n from obs where concept_id = 4663 -- ANC form \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.encounter_id = B.encounter_id \n where B.concept_id = 1740 and B.value_coded = 1016 -- HIV Negative \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n)Test_during_pregnancy \n \ninner join \n-- Gestational age \n( \n select B.person_id,obs_group_id,encounter_id \n from obs B \n where B.concept_id = 1923 and B.value_numeric >= 36 -- Gestation period \n and CAST(B.obs_datetime as date) >= CAST(:startDate as date) \n and CAST(B.obs_datetime as date) <= CAST(:endDate as date) \n and voided = 0 \n)gestational_age \non gestational_age.encounter_id = Test_during_pregnancy.encounter_id \n)\n','2024-06-13 15:48:16',4,'2024-06-13 15:49:42',4,0,NULL,NULL,NULL,'9e878c4f-04ff-4edc-84f4-553c465229b5'); /*!40000 ALTER TABLE `serialized_object` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -84,4 +85,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2024-05-13 16:12:06 +-- Dump completed on 2024-06-13 16:05:44